+ Reply to Thread
Results 1 to 2 of 2

How to select a range using a counter

Hybrid View

  1. #1
    Registered User
    Join Date
    02-28-2005
    Posts
    2

    How to select a range using a counter

    Hi

    I'm trying to select a range of cells using a counter. The idea is to use a cell to track the number of rows the spreadsheet has, and increment it each time a row is added. I want the macro to evaluate this number and select the range accordingly (i.e. counter+1). I'm struggling to work out how to get VBA to pick up the value of the cell and then use it as a cell reference as part of a range.

    I want something like this:

    Range("A[counter+1] : AI [counter +1]").Select

    Counter += 1

    Hope this makes sense, any help would be greatly appreciated
    Thanks

  2. #2
    Forum Contributor
    Join Date
    11-16-2004
    Posts
    282
    Here's one way to do what you need:

    Dim lastRow
    lastRow = ActiveSheet.UsedRange.Rows.Count
    Range("A" & lastRow & ": AI" & lastRow).Select
    Hope this helps,
    theDude

+ 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