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 create a varying named range

What I want to do is have a macro that selects all cells containing
data, creates a range and names it "Print_Area" sounds simple, but I
cannot get it to work

ActiveSheet.UsedRange.Select
ActiveWorkbook.Names.Add Name:="Print_Area", RefersToR1C1:= _
"=R396070CS01!R1C1:R38C17"

Ive got that, which works fine, however, i need to to be run in many
spreadsheets, with varying sheet names, and varying cell ranges.

Ideas...??
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default Macro to create a varying named range

Try following:

ActiveSheet.UsedRange.Select
Selection.Name = "Print_Area"

regards
reklamo


" wrote:

What I want to do is have a macro that selects all cells containing
data, creates a range and names it "Print_Area" sounds simple, but I
cannot get it to work

ActiveSheet.UsedRange.Select
ActiveWorkbook.Names.Add Name:="Print_Area", RefersToR1C1:= _
"=R396070CS01!R1C1:R38C17"

Ive got that, which works fine, however, i need to to be run in many
spreadsheets, with varying sheet names, and varying cell ranges.

Ideas...??

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Macro to create a varying named range

Won't clearing the print area let excel just use the usedrange?

Dim Wks as worksheet
for each wks in activeworkbook.worksheets
wks.PageSetup.PrintArea = ""
next wks

But if you want...

Dim Wks as worksheet
for each wks in activeworkbook.worksheets
wks.usedrange.name = "'" & wks.name & "'!Print_Area"
next wks


wrote:

What I want to do is have a macro that selects all cells containing
data, creates a range and names it "Print_Area" sounds simple, but I
cannot get it to work

ActiveSheet.UsedRange.Select
ActiveWorkbook.Names.Add Name:="Print_Area", RefersToR1C1:= _
"=R396070CS01!R1C1:R38C17"

Ive got that, which works fine, however, i need to to be run in many
spreadsheets, with varying sheet names, and varying cell ranges.

Ideas...??


--

Dave Peterson
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
Macro - Varying Range to Copy HROBERTSON Excel Programming 1 February 7th 07 08:43 PM
Create univeral pivot table macro - use with varying lenght data sets rsulliva Excel Programming 1 September 14th 06 01:47 AM
Create Named Range in VBA michael.a7[_5_] Excel Programming 2 June 9th 06 12:00 AM
Create named range Matee Excel Programming 1 April 4th 06 03:40 AM
Using Varying Range Size in Macro Charles Allen[_2_] Excel Programming 1 May 16th 05 12:48 AM


All times are GMT +1. The time now is 08:18 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"