Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Macro to edit Range Name

I have sheets in a workbook that have rows added each month. These
sheets have named ranges but, once the new data is added I need to
expand the name ranges to include the new rows. I have been
unsuccesful in writing a macro that can adjust the name ranges to
include the new rows. The ranges are always row 1 through the last row
in a specified column.

Can anyone help?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Macro to edit Range Name

I'm still fiddling with this and thought I had the answer. The range
should just be the data in a particular column. When I use the
following macro, the range ends up being ALL of the data on the sheet.
Any ideas what I am doing wrong?

Sheets("Sheet2").Select
Range("A4").Select
Range(Selection, Selection.End(xlDown)).Select
Range("rangea").CurrentRegion.Name = "rangea"


Range("B4").Select
Range(Selection, Selection.End(xlDown)).Select
Range("rangeb").CurrentRegion.Name = "rangeb"

Range("C4").Select
Range(Selection, Selection.End(xlDown)).Select
Range("rangec").CurrentRegion.Name = "rangec"

Range("D4").Select
Range(Selection, Selection.End(xlDown)).Select
Range("ranged").CurrentRegion.Name = "ranged"

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Macro to edit Range Name

Hi Eric,

One way, perhaps:

'=============
Public Sub Tester01()
Dim RngA As Range
Dim RngB As Range
Dim RngC As Range
Dim RngD As Range
Const sStr As String = "A4"

With Range(sStr)
Set RngA = .CurrentRegion.Columns(1)
Set RngB = .CurrentRegion.Columns(2)
Set RngC = .CurrentRegion.Columns(3)
Set RngD = .CurrentRegion.Columns(4)
End With
End Sub
'<<=============

---
Regards,
Norman


wrote in message
oups.com...
I'm still fiddling with this and thought I had the answer. The range
should just be the data in a particular column. When I use the
following macro, the range ends up being ALL of the data on the sheet.
Any ideas what I am doing wrong?

Sheets("Sheet2").Select
Range("A4").Select
Range(Selection, Selection.End(xlDown)).Select
Range("rangea").CurrentRegion.Name = "rangea"


Range("B4").Select
Range(Selection, Selection.End(xlDown)).Select
Range("rangeb").CurrentRegion.Name = "rangeb"

Range("C4").Select
Range(Selection, Selection.End(xlDown)).Select
Range("rangec").CurrentRegion.Name = "rangec"

Range("D4").Select
Range(Selection, Selection.End(xlDown)).Select
Range("ranged").CurrentRegion.Name = "ranged"



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Macro to edit Range Name

Norman, sorry to be simple minded but I ran that macro and it doesn't
appear that anything happened.

Eric

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Macro to edit Range Name

Hi Eric,

Norman, sorry to be simple minded but I ran that macro and it doesn't
appear that anything happened.


I suspect I misinterpreted your intentions. Try:

'=============
Public Sub Tester01A()

With Range("A4")
Names.Add Name:="RangeA", RefersTo:=.CurrentRegion.Columns(1)
Names.Add Name:="RangeB", RefersTo:=.CurrentRegion.Columns(2)
Names.Add Name:="RangeC", RefersTo:=.CurrentRegion.Columns(3)
Names.Add Name:="RangeD", RefersTo:=.CurrentRegion.Columns(4)
End With
End Sub
'<<=============

---
Regards,
Norman


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
Record Macro and Edit Macro options disabled Huzza New Users to Excel 1 March 18th 09 03:55 PM
allow users to edit range Lp12 Excel Discussion (Misc queries) 0 March 21st 06 12:20 PM
How do I edit a selected range then copy the range into an new sheet??? dwyborn Excel Programming 2 December 16th 05 04:11 PM
How to edit a named range Wanson Excel Discussion (Misc queries) 0 December 8th 05 04:23 PM
Highlight Range - wrong macro, please edit. Danny Excel Worksheet Functions 8 October 19th 05 11:11 PM


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

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"