LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default How can I change range name definitions as the No. of rows change.

Sub CreateNames()
Dim lastrow As Long
lastrow = Cells(Rows.Count, 1).End(xlUp).Row
Range("A1").Resize(lastrow, 3).Name = "ABC"
Range("ABC").Resize(, 7).Name = "AtoG"
Range("ABC").Offset(0, 5).Resize(, 2).Name = "FG"
End Sub

just for demonstartion purposes, after running this I tested the results in
the immediate window:

? activeworkbook.Names("ABC").RefersTo
=Sheet1!$A$1:$C$27
? activeworkbook.Names("AtoG").RefersTo
=Sheet1!$A$1:$G$27
? activeworkbook.Names("FG").RefersTo
=Sheet1!$F$1:$G$27

Look good to me.

--
Regards,
Tom Ogilvy




wrote in message
oups.com...
I import data from an accounting application. The columns are always
fixed at 7.. The number of rows will vary.

3 ranges are used in functions and a pivot tables.

ABC A1.C1 down to last row.
AtoG A1. G1 down to last row
FG F1.G1 down to last row.

The last row is the same for all 3 ranges.

Can anyone suggest the VBA code needed to accomplish this. I know
very little aboutr VBA . I just know enough to copy and paste new code
into code compiled by recording a macro.-

Thanks,

Harvey Snyder
Providence, RI




 
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
How can change range to select active rows instead of :=Range("S10 ldiaz Excel Discussion (Misc queries) 7 August 29th 08 03:52 PM
Trouble with 2 range definitions ... Celt[_39_] Excel Programming 7 April 5th 06 04:45 PM
excel deleting rows last cell does not change. How to change? mrubey Excel Discussion (Misc queries) 3 August 25th 05 08:38 PM
Change Rows/Columns in range??? 43fan Excel Programming 0 April 1st 04 02:05 PM
Change Rows/Columns in range??? 43fan Excel Programming 0 April 1st 04 02:05 PM


All times are GMT +1. The time now is 12:12 AM.

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

About Us

"It's about Microsoft Excel"