View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Bill_Green via OfficeKB.com Bill_Green via OfficeKB.com is offline
external usenet poster
 
Posts: 8
Default Cell A1 to sheet name

I was able to get it to apply to all sheets, and yes it needs to pull from B1
on every sheet. Can I get it to hit only the selected sheets? Here's the code
I have now:

Sub Macro2()
'
' Macro2 Macro
' Macro recorded 8/4/2008 by bgreen
Dim sh As Worksheet
For i = 1 To Sheets.Count
Set sh = Sheets(i)
sh.Activate

With ActiveSheet
.Name = .Range("B1").Value
End With

Next i
End Sub

The actual name of the product is in cell A1, but it's very long and the
first 15 digits are the same or close to it on most of them, so I selected
the appropriate sheets and put this formula in cell B1 '=MID(A1,16,31)' to
get past the digits that are the same and since the name of the tab has to be
less than 31 characters long, then copied and pasted special "values." This
is a lot of steps.

Dave Peterson wrote:
How many worksheets are in this workbook--87? (Any worksheets to avoid???)

Do you want each worksheet named after what's found in B1 of that particular
worksheet?

Do the values in B1 change often?

If yes, then you could use a workbook event (instead of 87 separat worksheet
events) -- but that would depend on knowing the names of the sheets to be
avoided, too.

If no, then you could use a macro that would cycle through the worksheets and
change the names accordingly--and if the values in B1 change, you could just run
the macro when you wanted to. You wouldn't need excel to always be looking for
a change.

I am trying to make 87 sheets in a workbook change their name to reflect that
of what is in cell B1. Is there a way to do that in VBA? I've tried it onthe

[quoted text clipped - 21 lines]
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200808/1



--
Message posted via http://www.officekb.com