+ Reply to Thread
Results 1 to 4 of 4

Re-defining Ranges in VBA

Hybrid View

  1. #1
    aehan
    Guest

    Re-defining Ranges in VBA

    Can anyone help please? I have a macro which imports data, replacing data
    which is already there and has been range named. When the import has
    finished, the range name re-defines itself and cuts out some of the columns
    and rows that were originally there.

    Is there a way in VBA that I can get therange name to automatically
    re-define itself based on the new current region so that it sees all of the
    new data?

    I'm new at this and I'm struggling, so any help would be really appreciated

    Thanks

  2. #2
    Jim Thomlinson
    Guest

    RE: Re-defining Ranges in VBA

    Once all of your cutting and pasting is done you can use code something like
    this...

    ThisWorkbook.Names.Add "RawData",
    Range(activesheet.Range("A65535").End(xlUp), activesheet.Range("C1"))

    This code creates a named range (RawData) from from the last row of data in
    column A to the first row in column C...

    HTH

    "aehan" wrote:

    > Can anyone help please? I have a macro which imports data, replacing data
    > which is already there and has been range named. When the import has
    > finished, the range name re-defines itself and cuts out some of the columns
    > and rows that were originally there.
    >
    > Is there a way in VBA that I can get therange name to automatically
    > re-define itself based on the new current region so that it sees all of the
    > new data?
    >
    > I'm new at this and I'm struggling, so any help would be really appreciated
    >
    > Thanks


  3. #3
    aehan
    Guest

    RE: Re-defining Ranges in VBA

    THANKYOU!!!!!

    "Jim Thomlinson" wrote:

    > Once all of your cutting and pasting is done you can use code something like
    > this...
    >
    > ThisWorkbook.Names.Add "RawData",
    > Range(activesheet.Range("A65535").End(xlUp), activesheet.Range("C1"))
    >
    > This code creates a named range (RawData) from from the last row of data in
    > column A to the first row in column C...
    >
    > HTH
    >
    > "aehan" wrote:
    >
    > > Can anyone help please? I have a macro which imports data, replacing data
    > > which is already there and has been range named. When the import has
    > > finished, the range name re-defines itself and cuts out some of the columns
    > > and rows that were originally there.
    > >
    > > Is there a way in VBA that I can get therange name to automatically
    > > re-define itself based on the new current region so that it sees all of the
    > > new data?
    > >
    > > I'm new at this and I'm struggling, so any help would be really appreciated
    > >
    > > Thanks


  4. #4
    Tom Ogilvy
    Guest

    Re: Re-defining Ranges in VBA

    Unless you have set the range definition up as a dynamic range, it wouldn't
    be automatic, but since you are running code to make the changes, just add a
    line similar to this.

    Range("A1").CurrentRegion.Name = "MyName"

    --
    Regards,
    Tom Ogilvy

    "aehan" <aehan@discussions.microsoft.com> wrote in message
    news:5503497A-930A-48BD-B859-040B5BED898F@microsoft.com...
    > Can anyone help please? I have a macro which imports data, replacing data
    > which is already there and has been range named. When the import has
    > finished, the range name re-defines itself and cuts out some of the

    columns
    > and rows that were originally there.
    >
    > Is there a way in VBA that I can get therange name to automatically
    > re-define itself based on the new current region so that it sees all of

    the
    > new data?
    >
    > I'm new at this and I'm struggling, so any help would be really

    appreciated
    >
    > Thanks




+ 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