Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 983
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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" wrote in message
...
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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Defining a name that represent identical ranges in every sheet Bernard Excel Discussion (Misc queries) 1 August 31st 06 02:18 PM
Defining Ranges Steve Excel Worksheet Functions 5 May 28th 05 07:41 AM
Defining Dynamic Ranges in Macro Prashant Garg Excel Programming 2 December 17th 04 01:47 AM
Defining ranges in VB code Rachael Moody Excel Programming 5 January 27th 04 02:21 PM
Defining Ranges Greg Ghavalas Excel Programming 2 July 9th 03 10:10 PM


All times are GMT +1. The time now is 03:07 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"