+ Reply to Thread
Results 1 to 10 of 10

Extracting values from A1, A11, A21

  1. #1
    Registered User
    Join Date
    03-29-2011
    Location
    Durham, United States
    MS-Off Ver
    Excel 2007
    Posts
    5

    Extracting values from A1, A11, A21

    Hi,

    I am trying to write a vba code to find values from A1, A11, A21 and so on. It would be great if someone could help me with that.

    The variables that I know are:

    Range (A1:A21000)

    and primarily looking to find A1, A1 + 10.

    I am attempting to use VBA after a long time and it would be useful to get some help.

    Thanks,
    Last edited by allstarbiotech; 03-29-2011 at 08:54 PM. Reason: Grammar!

  2. #2
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Extracting values from A1, A11, A21

    For example:
    Please Login or Register  to view this content.
    Remember what the dormouse said
    Feed your head

  3. #3
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Extracting values from A1, A11, A21

    Welcome to the Forum!

    What do you mean by "find values"? You mean search for values, or just iterate through all those cells?

    This will iterate through all those cells:
    Please Login or Register  to view this content.
    Edit: I like romperstomper's a little better
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  4. #4
    Registered User
    Join Date
    03-29-2011
    Location
    Durham, United States
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Extracting values from A1, A11, A21

    Thanks for the replies so far.

    I need to print the integer values in a new column.

  5. #5
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Extracting values from A1, A11, A21

    Where? Can you not just use formulas instead of VBA?

  6. #6
    Registered User
    Join Date
    03-29-2011
    Location
    Durham, United States
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Extracting values from A1, A11, A21

    I can't find any formula that would find and 'print' integer values from rows A1, A11 and so on.

    By printing I mean, to get the values from these particular cells to another column.

    I am basically looking to reduce a data set from ~20000 numbers to about 2000 and thus want to select every 10th cell in the column. Hope this makes it better.

  7. #7
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Extracting values from A1, A11, A21

    In b1:
    =INDEX(A:A,(row()-1)*10+1)
    and copy down to B2000.

  8. #8
    Registered User
    Join Date
    03-29-2011
    Location
    Durham, United States
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Extracting values from A1, A11, A21

    Thanks. this made it much simpler. Can you tell what does the row()-1, the [reference] parentheses are for?

  9. #9
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Extracting values from A1, A11, A21

    ROW() returns the row number of the cell containing the formula.
    Since we want every tenth row starting at row 1, we subtract 1 from the row, multiply by 10 and add 1, so this part:
    (row()-1)*10+1
    in row 1 evaluates to: (1 - 1)*10 + 1 = 0*10 + 1 = 1
    in row 2 evaluates to: (2 - 1)*10 + 1 = 1*10 + 1 = 11
    and so on.

  10. #10
    Registered User
    Join Date
    03-29-2011
    Location
    Durham, United States
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Extracting values from A1, A11, A21

    Thanks man, appreciate all the help. It worked out fine. I am looking forward to writing a simple code to test this using vba as well.

    Cheers

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1