Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Indirect Naming of Workbooks

Status
Not open for further replies.

jnix

MIS
Feb 18, 2002
101
US
You all have helped me in indirect naming of my worksheets, now is it possible to name a workbook based on a field in that workbook? If so, how?
Thanks,
jnix
 
Skip:
When I try this in a macro at runtime, all it does is open another workbook.
jnix
 
As far as I know the only way to apply a name to a workbook is to save it with the required name.

[tab]ActiveWorkbook.SaveAs [A1] & ".xls"

Or have I missed something ?

A.C.
 

Here's my macro. When I run it, it opens a new workbook, but doesn't save anything.

Sub Worksheet_Name()



Worksheets("Base").Name = Range("k1")
Worksheets("1st Quarter").Name = Range("K1") & " 1st Quarter"
Worksheets("2nd Quarter").Name = Range("K1") & " 2nd Quarter"
Worksheets("3rd Quarter").Name = Range("K1") & " 3rd Quarter"
Worksheets("4th Quarter").Name = Range("K1") & " 4th Quarter"

ActiveWorkbook.SaveAs (K1) & ".xls"

End Sub

Any suggestions will be appreciated
Thanks,
jnix
 
jnix,

I assume that you are trying to name your sheets, so they are presumably sheet1, etc.

Try:

Sub Worksheet_Name()

Worksheets("Sheet1").Name = Range("K1")
Worksheets("Sheet2").Name = Range("K1") & " 1st Quarter"
Worksheets("Sheet3").Name = Range("K1") & " 2nd Quarter"
Worksheets("Sheet4").Name = Range("K1") & " 3rd Quarter"
Worksheets("Sheet5").Name = Range("K1") & " 4th Quarter"

ActiveWorkbook.SaveAs (K1) & ".xls"

End Sub

hth

Henio
 
try this
myPath = "C:\"
ActiveWorkbook.SaveAs myPath & [K1] & ".xls"


Rgds, Geoff
[blue]Si hoc signum legere potes, operis boni in rebus Latinus alacribus et fructuosis potiri potes![/blue]
Want the [red]best[/red] answers to your questions ? faq222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top