![]() |
select a range in a macro
I am trying to name a variable range in a macro. I have recorded the
actions, but it always references the range in R1C1 terms - which therefore always selcts the exact same area, not the variable area. The code I am using is below. I want to change the "ActiveWorkbook.Names......" line to use the CurrentRegion I have selected in the line above. BUT i dont know how. Any help gratefully accepted. Thanks Andrew Sub Macro9() ' Range("A1").Select Selection.CurrentRegion.Select ActiveWorkbook.Names.Add Name:="obook", RefersToR1C1:= _ "=production!R1C1:R144C28" Range("A1").Select End Sub |
select a range in a macro
Selection.CurrentRegion.Name = "obook"
-- HTH Bob Phillips (remove xxx from email address if mailing direct) "Andrew" wrote in message ... I am trying to name a variable range in a macro. I have recorded the actions, but it always references the range in R1C1 terms - which therefore always selcts the exact same area, not the variable area. The code I am using is below. I want to change the "ActiveWorkbook.Names......" line to use the CurrentRegion I have selected in the line above. BUT i dont know how. Any help gratefully accepted. Thanks Andrew Sub Macro9() ' Range("A1").Select Selection.CurrentRegion.Select ActiveWorkbook.Names.Add Name:="obook", RefersToR1C1:= _ "=production!R1C1:R144C28" Range("A1").Select End Sub |
select a range in a macro
Thanks Bob - Fantastic!
"Bob Phillips" wrote: Selection.CurrentRegion.Name = "obook" -- HTH Bob Phillips (remove xxx from email address if mailing direct) "Andrew" wrote in message ... I am trying to name a variable range in a macro. I have recorded the actions, but it always references the range in R1C1 terms - which therefore always selcts the exact same area, not the variable area. The code I am using is below. I want to change the "ActiveWorkbook.Names......" line to use the CurrentRegion I have selected in the line above. BUT i dont know how. Any help gratefully accepted. Thanks Andrew Sub Macro9() ' Range("A1").Select Selection.CurrentRegion.Select ActiveWorkbook.Names.Add Name:="obook", RefersToR1C1:= _ "=production!R1C1:R144C28" Range("A1").Select End Sub |
select a range in a macro
Thanks Bob - Fantastic
"Bob Phillips" wrote: Selection.CurrentRegion.Name = "obook" -- HTH Bob Phillips (remove xxx from email address if mailing direct) "Andrew" wrote in message ... I am trying to name a variable range in a macro. I have recorded the actions, but it always references the range in R1C1 terms - which therefore always selcts the exact same area, not the variable area. The code I am using is below. I want to change the "ActiveWorkbook.Names......" line to use the CurrentRegion I have selected in the line above. BUT i dont know how. Any help gratefully accepted. Thanks Andrew Sub Macro9() ' Range("A1").Select Selection.CurrentRegion.Select ActiveWorkbook.Names.Add Name:="obook", RefersToR1C1:= _ "=production!R1C1:R144C28" Range("A1").Select End Sub |
All times are GMT +1. The time now is 02:43 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com