Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 137
Default Define Named Range

Hi,

For my first 12 worksheets I would like to add named range starting
from column I to Z.

say if my first 12 sheets are named as JAN thru DEC then what I am
looking for is a code to define range name from row 3 to 15 of each
sheet with sheet name and column name.

so for eg. in sheet JAN I3:I5 will be named as JANI and Z3 to Z15 as
JANK. this way for all 12 sheets

How can I do this?

Thanks

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default Define Named Range

i was kind of in a hurry, so please test this out thoroughly

put the code below in a regular code module

press control - g to see the immediate window if it's not already visible and
execute the macro

when you run this code, it will create ranges for the first 12 sheets, hopefully
your first 12 are jan - dec

then, create a new sub and copy and paste all the immediate window code into
this new module and run it.

hopefully it will create the ranges you want.


Sub name_ranges2() ' this creates the named range for each sheet
Dim nm As Name
Dim i As Long, c As Long, k As Long
k = 3
For i = 1 To 3
For c = 12 To 26
sname = Worksheets(i).Name
Debug.Print "ActiveWorkbook.Names.Add Name:=" & """" & Worksheets(i).Name &
Right(Left(Cells(3, c).Address, 2), 1) & """" & _
", Refersto:=""" & "=" & sname & "!" & Range(Cells(3, c), Cells(15,
c)).Address & """"
Next
k = k + 1
Next
End Sub

--


Gary


"Abdul" wrote in message
ups.com...
Hi,

For my first 12 worksheets I would like to add named range starting
from column I to Z.

say if my first 12 sheets are named as JAN thru DEC then what I am
looking for is a code to define range name from row 3 to 15 of each
sheet with sheet name and column name.

so for eg. in sheet JAN I3:I5 will be named as JANI and Z3 to Z15 as
JANK. this way for all 12 sheets

How can I do this?

Thanks



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
How do I have a cell value define a dynamic named range? CellShocked Excel Worksheet Functions 15 October 26th 11 02:08 AM
How to define a relative named range in VBA John Broderick Excel Programming 10 December 24th 05 03:03 PM
How to define a Named Range in VBA? Richard Excel Programming 3 December 12th 05 06:49 PM
Define a range based on another named range Basil Excel Worksheet Functions 2 February 21st 05 01:47 PM
Help with named constants in Define Name dialog box!!!! ilona Excel Programming 3 May 1st 04 12:01 AM


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