ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Naming work sheet the name as sub-routine that creates it (https://www.excelbanter.com/excel-worksheet-functions/205031-naming-work-sheet-name-sub-routine-creates.html)

Rich Mogy

Naming work sheet the name as sub-routine that creates it
 
I have a macro that I'm trying to create several work sheets, and then put
information retrieved from a SQL database. I would like the name of each
worksheet to be the same as the sub routine that created it. Is this
possible through the code --

sub myworksheet
worksheets.add
worksheets.name(x) where x is the name of the sub
end sub

Thanks in advance.

Rich Mogy


JP[_4_]

Naming work sheet the name as sub-routine that creates it
 
This might not be terribly helpful, but you can give a worksheet any
name you want, provided it is <= 26 characters (which I believe is the
limit for the sheet tab).

--JP

On Oct 3, 5:02*pm, "Rich Mogy" wrote:
I have a macro that I'm trying to create several work sheets, and then put
information retrieved from a SQL database. *I would like the name of each
worksheet to be the same as the sub routine that created it. *Is this
possible through the code --

sub myworksheet
worksheets.add
worksheets.name(x) where x is the name of the sub
end sub

Thanks in advance.

Rich Mogy



Rich Mogy

Naming work sheet the name as sub-routine that creates it
 
Understood -- but I want to use the naming convention I have described.

"JP" wrote in message
...
This might not be terribly helpful, but you can give a worksheet any
name you want, provided it is <= 26 characters (which I believe is the
limit for the sheet tab).

--JP

On Oct 3, 5:02 pm, "Rich Mogy" wrote:
I have a macro that I'm trying to create several work sheets, and then put
information retrieved from a SQL database. I would like the name of each
worksheet to be the same as the sub routine that created it. Is this
possible through the code --

sub myworksheet
worksheets.add
worksheets.name(x) where x is the name of the sub
end sub

Thanks in advance.

Rich Mogy



Don Guillett

Naming work sheet the name as sub-routine that creates it
 
I have never tried to determine the name of a sub being fired. You say
several. ?? Why not make a list with a for each item in the list create the
sheet and name it for the item. ONE sub.
sub dd()
Sheets.Add
ActiveSheet.Name = "dd"
end sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Rich Mogy" wrote in message
...
I have a macro that I'm trying to create several work sheets, and then put
information retrieved from a SQL database. I would like the name of each
worksheet to be the same as the sub routine that created it. Is this
possible through the code --

sub myworksheet
worksheets.add
worksheets.name(x) where x is the name of the sub
end sub

Thanks in advance.

Rich Mogy



Barb Reinhardt

Naming work sheet the name as sub-routine that creates it
 
Don,

I've listed all the procedures in a module using info from here.

http://www.cpearson.com/excel/vbe.aspx

But I think your way is far easier to do.

Barb Reinhardt


"Don Guillett" wrote:

I have never tried to determine the name of a sub being fired. You say
several. ?? Why not make a list with a for each item in the list create the
sheet and name it for the item. ONE sub.
sub dd()
Sheets.Add
ActiveSheet.Name = "dd"
end sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Rich Mogy" wrote in message
...
I have a macro that I'm trying to create several work sheets, and then put
information retrieved from a SQL database. I would like the name of each
worksheet to be the same as the sub routine that created it. Is this
possible through the code --

sub myworksheet
worksheets.add
worksheets.name(x) where x is the name of the sub
end sub

Thanks in advance.

Rich Mogy




Rich Mogy

Naming work sheet the name as sub-routine that creates it
 
Thanks to everyone who replied. I think this will handle it.
"Barb Reinhardt" wrote in message
...
Don,

I've listed all the procedures in a module using info from here.

http://www.cpearson.com/excel/vbe.aspx

But I think your way is far easier to do.

Barb Reinhardt


"Don Guillett" wrote:

I have never tried to determine the name of a sub being fired. You say
several. ?? Why not make a list with a for each item in the list create
the
sheet and name it for the item. ONE sub.
sub dd()
Sheets.Add
ActiveSheet.Name = "dd"
end sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Rich Mogy" wrote in message
...
I have a macro that I'm trying to create several work sheets, and then
put
information retrieved from a SQL database. I would like the name of
each
worksheet to be the same as the sub routine that created it. Is this
possible through the code --

sub myworksheet
worksheets.add
worksheets.name(x) where x is the name of the sub
end sub

Thanks in advance.

Rich Mogy






All times are GMT +1. The time now is 10:55 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com