Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 107
Default Adding Name Range to this macro

Afternoon,

I have this macro:

Sub NameSheets()
'will add a sheet, and name it
'for each name in column A
'from A1 down till it hits a blank row
Dim Rng As Range
Dim ListRng As Range
Set ListRng = Range(Range("A1"), Range("A1").End(xlDown))
For Each Rng In ListRng
If Rng.Text < "" Then
With Worksheets
..Add(after:=.Item(.Count)).Name = Rng.Text
End With
End If
Next Rng
End Sub

Which creates the number of sheets according to the number of names I have
listed.

Now I have a formula above the names:

=IF($B$3<"",ADDRESS(ROW($B$3),COLUMN($B$3),1)&":" &ADDRESS(ROW($B$3)+COUNTA($B$3:$B$104)-1,COLUMN($B$3)),"")

To only count the number of names that are listed, because the number of
names will change month to month.
If I create a Name Range over this formula and substitute the Name Range in
place of A1 in the macro, it comes back with an error about having entered an
invalid name try name not exceeding 31 characters (NameRange is what I have
used), make sure name does not contain : \ / ? * [ or ]

So I ask if someone can assist in inserting a name range instead of A1 as
the number of names will change month to month.

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
Naming a range during macro execution Kevryl Excel Discussion (Misc queries) 2 December 11th 06 10:08 AM
error when running cut & paste macro Otto Moehrbach Excel Worksheet Functions 4 August 9th 06 01:49 PM
Macro to hide blank cells in a range Dave Excel Discussion (Misc queries) 1 February 1st 06 11:55 PM
checking that cells have a value before the workbook will close kcdonaldson Excel Worksheet Functions 8 December 5th 05 04:57 PM
Closing File Error jcliquidtension Excel Discussion (Misc queries) 4 October 20th 05 12:22 PM


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