+ Reply to Thread
Results 1 to 3 of 3

Moving a Range

  1. #1
    Registered User
    Join Date
    11-14-2008
    Location
    Tampa
    MS-Off Ver
    Professional Plus 2007
    Posts
    30

    Moving a Range

    Is there a way to write VBA code that can reference a range of data that may be moved on the spreadsheet by the User?

    For example, if I write VBA code to reference a range of data such as:
    Please Login or Register  to view this content.
    then I can't "move" the range in the spreadsheet and expect the code to work. How can I code the range of data in VBA, so I am able to move it around and its location tracked by VBA? Is it possible?
    Last edited by costadina; 04-30-2009 at 02:47 PM.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Moving a Range

    Highlight the cells in their current location on the sheet and give the range a Name. Click in the NameBox (just to the left of the formula bar) and type in something like:
    MovingRange

    Now that those cells as a group have a name, VBA can use it, too.
    Please Login or Register  to view this content.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    11-14-2008
    Location
    Tampa
    MS-Off Ver
    Professional Plus 2007
    Posts
    30

    Re: Moving a Range

    Thanks a bunch

+ 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