Consulting

Results 1 to 10 of 10

Thread: Solved: Change/Update Defined Names 'Ranges' (multiple) in Name Manager

  1. #1

    Solved: Change/Update Defined Names 'Ranges' (multiple) in Name Manager

    Hi Guys,

    Is it possible to change multiple Defined Names Ranges in excel Name Manager.

    So, let's say I have defined some names in the excel file but somehow there was a need to change the ranges in defined names. We can update the ranges if we have few but what if we have multiple defined ranges. It will be double the effort and consume a lot of time.

    Please advise..

    Thanks,
    Regards,
    Manoj

    "There are no failures - just experiences and your reactions to them."

  2. #2
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    [VBA]Dim Sht as Worksheet
    For each Sht is Worksheets
    Sht.PrintArea= Sht.UsedRange.Address
    Next Sht[/VBA]
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  3. #3
    Hi Sam,

    Thanks for the code. However, I tried to run it but it is giving me an error.

    Would you be able to share a working file?
    Regards,
    Manoj

    "There are no failures - just experiences and your reactions to them."

  4. #4
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,060
    Location
    What is the error being given?
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  5. #5
    It's giving me 'Compile error: Method or data member not found' message.

    Thanks,
    Regards,
    Manoj

    "There are no failures - just experiences and your reactions to them."

  6. #6
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    My typo error

    "Is" = "In"
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  7. #7
    Sorry guys.. I don't know what I'm doing wrong..but it is still giving me the same error message.
    Regards,
    Manoj

    "There are no failures - just experiences and your reactions to them."

  8. #8
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,060
    Location
    Quote Originally Posted by vishwakarma
    Hi Guys,

    Is it possible to change multiple Defined Names Ranges in excel Name Manager.
    Surely Name Manager gives you that option? And seriously if you need to change the ranges that often then the problem is not in Name Manager but in how the ranges are being constructed or Named. Look deeper into the issue.
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  9. #9
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    Manoj,

    Sorry about that.

    I wrote the above code in the VBAX editor, and I really, really should have used the VBA editor. (me)

    [vba]Sub test()
    Dim Sht As Worksheet
    For Each Sht In Worksheets

    Sht.PageSetup.PrintArea = Sht.UsedRange.Address

    Next Sht

    End Sub[/vba]
    In the VBE, as soon as I put the cursor in "PrintArea" and pressed F1, I saw the answer in a second.

    You need to be aware that Excel does not do a very good job of updating UsedRange. If all your sheets have data in in cell "A1" you should instead use: [vba]Range("A1").CurrentRegion[/vba]

    The current region is a range bounded by any combination of blank rows and blank columns. Read-only.
    If you want to print a specific area, use an address string instead of a sheet range, [vba]Dim PA as String
    PA = "A1:X99"
    Sht.PageSetup.PrintArea = PA[/vba]
    Last edited by SamT; 07-16-2013 at 08:44 AM.
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  10. #10
    Thank You SamT.. This is exactly what I needed.
    Regards,
    Manoj

    "There are no failures - just experiences and your reactions to them."

Posting Permissions

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