Results 1 to 3 of 3
  1. #1
    Star Lounger
    Join Date
    Feb 2004
    Location
    Houston, Texas, USA
    Posts
    95
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Macro Help Needed (97/SR2)

    I need to write a macro that will do the following:

    - Read through column D in a spreadsheet
    - Each time it encounters the word "Introduction" in column D, increment a counter by 1
    - Place the new number in column A
    - Continue to place the new number in column A until it encounters "Introduction" again in column D

    I am sure this is simple but I am just not very adept yet with VBA.

    Thanks,
    Caroline

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Macro Help Needed (97/SR2)

    You could do this without VBA. Enter the following formula in A1:

    =COUNTIF($D$1:$D1,"introduction")

    Drag the fill handle (the little black square in the lower right corner of A1) down to fill down the formula as far as needed.

  3. #3
    3 Star Lounger
    Join Date
    Dec 2000
    Location
    Vancouver, Br. Columbia, Canada
    Posts
    268
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Macro Help Needed (97/SR2)

    You can do this without VBA, by using an "Array Formula"

    In the first row in column A that requires this facility, enter the following formula:
    <pre> <font color=blue>
    =SUM(IF(D$11="Introduction",1,0))</pre>

    </font color=blue>
    assuming that you are starting in row 1

    You must enter the formula by pressing ctrl-shift-enter to let Excel know it is an array formula - Excel will put a "curly brace" (like this - { }) around the formula.

    Copy the formula (drag and drop) down column A as far as you need.

    I have attached a sample file.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •