Consulting

Results 1 to 4 of 4

Thread: How to List Named-Ranges only from specific Sheet

  1. #1

    How to List Named-Ranges only from specific Sheet

    Hi all!

    Still having trouble with ranges...
    I can't seem to get right a way to run through Named Ranges that belong to only a given Sheet...and then do stuff to them.
    Any ideas??

    '--------sub beg-------------
    Sub LoopThruRanges()

    Dim rng_names As Variant
    Dim n As Variant


    Set rng_names = ThisWorkbook.Names


    For Each n In rng_names
    With Sheets("OnlyforThisSheet")
    MsgBox n 'debug
    End With
    Next

    End Sub
    '--------sub end---------------

    Thanks!

  2. #2
    VBAX Tutor lynnnow's Avatar
    Joined
    Jan 2005
    Location
    Mumbai, Maharashtra, India
    Posts
    299
    Location
    You need to change ThisWorkbook.Names to ActiveSheet.Names

  3. #3
    Quote Originally Posted by lynnnow
    You need to change ThisWorkbook.Names to ActiveSheet.Names
    It didn't work either ;(
    I also tried ActiveSheet("xxxx").Names, to no good. It apparently does not recognise any ranges in sheetxxx

  4. #4
    VBAX Tutor lynnnow's Avatar
    Joined
    Jan 2005
    Location
    Mumbai, Maharashtra, India
    Posts
    299
    Location
    try this

    [VBA]'Set rng_names = ThisWorkbook.Names
    For Each n In ActiveSheet.Names
    MsgBox n
    Next n[/VBA]

Posting Permissions

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