+ Reply to Thread
Results 1 to 5 of 5

loop through column values?

  1. #1
    Registered User
    Join Date
    12-22-2008
    Location
    Sweden
    Posts
    56

    loop through column values?

    Hi,
    What the easiest way of looping though the values in a column in a macro?

    How to you "call" the cells in the macro?
    Br

    Andy
    Last edited by 77anders; 02-05-2009 at 01:55 PM.

  2. #2
    Valued Forum Contributor Shijesh Kumar's Avatar
    Join Date
    05-26-2008
    Location
    Bangalore / India
    MS-Off Ver
    2000
    Posts
    717

    Re: loop through column values?

    U can reference a cell in macros using Cells( row_numner , col_number)

    There are several way to loop thro column.. suppose u want to loop thro column A

    First cell of column A is cells(1,1)


    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    12-22-2008
    Location
    Sweden
    Posts
    56

    Re: loop through column values?

    thanks alot.
    I don't really understand how to specify a certain workbook/sheet in the vba.
    Do you know how to?

  4. #4
    Valued Forum Contributor Shijesh Kumar's Avatar
    Join Date
    05-26-2008
    Location
    Bangalore / India
    MS-Off Ver
    2000
    Posts
    717

    Re: loop through column values?

    U can specify any worksheet in workbook by

    Sheet1.cells(1,1) -- it will refrence cell A1 ( row 1 col 1) of sheet1
    sheet2.cell(100,3) -- it will refere to cell C100 ( row 100 , col 3) of sheet3

    Workbooks("BOOK1").Activate --- This is used to refer to a workbook...

  5. #5
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988

    Re: loop through column values?

    Here's an example to loop through sheets. Use a select case or if statement for a specfic sheet

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    http://www.mvps.org/dmcritchie/excel/sheets.htm

    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

+ 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