How can I label a worksheet based on a cell in Excel?

G

Guest

I have a workbook with multiple worksheets and would like to know if there is
a way to label each worksheet based on info in cells on the first worksheet
of the workbook.

Don't know if this is even possible. The labels for the worksheets would be
text, not numbers or dates. Anyone know the answer to this one?
 
G

Guest

Here is a three sheet example. I am assuming that the first sheet has the
list of tab names in column A:


Sub Macro1()
' gsnu
Sheets(1).Name = Sheets(1).Cells(1, 1).Value
Sheets(2).Name = Sheets(1).Cells(2, 1).Value
Sheets(3).Name = Sheets(1).Cells(3, 1).Value
End Sub
 
G

Guest

Gary,

Thanks for the info. Can you tell me where to enter the macro code so this
will happen? Names are in column A, starting with line 11. How will that
change the code you posted.

Thanks for the reply. This is super helpful!
Karen
 
G

Guest

If the data starts at l;ine 11 rather than lin 1 then:


Sub Macro1()
' gsnu
Sheets(1).Name = Sheets(1).Cells(11, 1).Value
Sheets(2).Name = Sheets(1).Cells(12, 1).Value
Sheets(3).Name = Sheets(1).Cells(13, 1).Value
End Sub

Put it in a module. For further instructions see:


http://www.cpearson.com/excel/vbe.htm
 
G

Guest

This is great and for the most part, is working. One more question...

It looks like when I enter the code below and have it listed for the 65
worksheets in the book, if not all 65 cells are filled in it gives me an
error message in Microsoft Visual basic of "400".

Two questions:
Is there a way to include an IF statement so if all 65 cells do not have
data in them, it's ok?

Is there a way to have this auto input the cell data into the tab or will I
have to go to TOOLS, MACROS, RUN each time I want the data to show up?

Thanks for your help!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top