+ Reply to Thread
Results 1 to 3 of 3

Simple Count problem

  1. #1
    Forum Contributor
    Join Date
    07-01-2005
    Posts
    103

    Simple Count problem

    Obviously new to VBA.

    I want to run a while function depending on the number of rows on a second sheet. ex..

    a = 1
    While a <= Sheet(2).rows.count
    a = a + 1
    ...
    this doesn't work. Any help. Thanks much.

  2. #2
    Toppers
    Guest

    RE: Simple Count problem

    One way:

    This will loop through all rows based on row count of column A and assumes
    row 1 is a header; adjust starting value of r (=2) and column as required.

    Dim lastrow as Long, r as long

    lastrow=Sheet(2).Cells(rows.count,"A").end(xlup).row
    For r=2 to lastrow
    .......

    Next r

    HTH

    "Paul987" wrote:

    >
    > Obviously new to VBA.
    >
    > I want to run a while function depending on the number of rows on a
    > second sheet. ex..
    >
    > a = 1
    > While a <= Sheet(2).rows.count
    > a = a + 1
    > ...
    > this doesn't work. Any help. Thanks much.
    >
    >
    > --
    > Paul987
    > ------------------------------------------------------------------------
    > Paul987's Profile: http://www.excelforum.com/member.php...o&userid=24850
    > View this thread: http://www.excelforum.com/showthread...hreadid=517357
    >
    >


  3. #3
    Forum Contributor
    Join Date
    07-01-2005
    Posts
    103
    very nice. thank you.

+ 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