+ Reply to Thread
Results 1 to 3 of 3

Referencing a cell within a named range

  1. #1
    Registered User
    Join Date
    01-04-2005
    Posts
    2

    Referencing a cell within a named range

    Hi,

    I have several columns in a sheet, each is a named range. I need to be able to reference cells within these named ranges. For example, instead of ActiveCell.Offset (0,-3), I'd like to have something like ActiveCell.Offset (0,"Description") <I know this doesn't work>


    I've tried searching for a solution to this problem but with no luck. Perhaps I've overlooked something (plus I am new to VBA programming). I apologize if I'm missing the obvious, but can this be done? the project I'm working on moves these cells around a bit and I'd like the ability to refer to their data exclusively by the names and not in absolute terms.

    Thanks,
    Steve.

  2. #2
    Forum Contributor
    Join Date
    11-29-2003
    Posts
    1,203
    Let's say that the name of the range is "myRange".

    You can refer to the first cell in the range as:
    myRange.Cells(1)

    You can refer to the last cell in the range as:
    myRange.Cells(myRange.Cells.Count)

    You can do something with each cell in the range as follows (for example):
    For each c in myRange.Cells
    msgbox c.address
    next c

    Hope that helps.

    - Pete

  3. #3
    Registered User
    Join Date
    01-04-2005
    Posts
    2
    Thanks for the reply. I actually had to substitute

    Range("<the target range name>")

    for myRange in your examples but once I did, it worked perfectly.

    Thanks!
    Steve.

+ 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