Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
Andrew
 
Posts: n/a
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.misc
Bob Phillips
 
Posts: n/a
Default 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



  #3   Report Post  
Posted to microsoft.public.excel.misc
Andrew
 
Posts: n/a
Default 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




  #4   Report Post  
Posted to microsoft.public.excel.misc
Andrew
 
Posts: n/a
Default 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




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
Copy/Paste using a macro that identifies occuoied range JorgeAE Setting up and Configuration of Excel 1 March 13th 06 12:51 AM
consolidation of tables in excel with text and figures samenvoegen van sheets Excel Worksheet Functions 8 March 2nd 06 03:27 PM
checking that cells have a value before the workbook will close kcdonaldson Excel Worksheet Functions 8 December 5th 05 04:57 PM
Name a Range - Macro Danny Excel Worksheet Functions 0 October 14th 05 05:24 AM
Match function...random search? Les Excel Worksheet Functions 10 July 28th 05 11:54 AM


All times are GMT +1. The time now is 08:22 PM.

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"