Consulting

Results 1 to 4 of 4

Thread: Solved: named ranges

  1. #1
    VBAX Tutor
    Joined
    Nov 2007
    Posts
    291
    Location

    Solved: named ranges

    Hello,

    If I have a named range say of cells A1 to AD1 which can grow and shrink i.e. users can add columns anywhere in the middle, is there a way of finding the last column in the current range (i.e. given its current size).

    I'd like to be able to find the column index i.e that it is column 28 for example

    Cheers
    Phil

  2. #2
    VBAX Master CreganTur's Avatar
    Joined
    Jan 2008
    Location
    Greensboro, NC
    Posts
    1,676
    Location
    Take a look at this www.vbaexpress.com/forum/showpost.php?p=156718 from MD, which shows how to create a dynamic named range. Now, his example will find the last used Row, not column, but you will be able to adjust it for Columns.
    -Randy Shea
    I'm a programmer, but I'm also pro-grammar!
    If your issue is resolved, please use Thread Tools to mark your thread as Solved!

    PODA (Professional Office Developers Association) | Certifiable | MOS: Access 2003


  3. #3
    VBAX Tutor
    Joined
    Nov 2007
    Posts
    291
    Location
    Thanks for that but I need to do it programmatically i.e. each time I run some code in the workbook I need to get the last column of a neamed range within VBA and assign it to a variable where I will use it elsewhere in the same Sub

    Thanks
    Phil

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    Range("myRange")(Range("myRange").Count).column
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

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