View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Otto Moehrbach Otto Moehrbach is offline
external usenet poster
 
Posts: 1,090
Default naming tab macro error runtime error 1004

Does B7 of each sheet have a formula that links back to the Master sheet?
If so, your problem is that each of these formulas links back to a specific
cell in the Master sheet. When you sort the Master sheet list, each formula
will calculate and try to name the Me sheet the new name that is now in the
linked cell.
Not knowing everything you are doing, it is difficult to give advice.
You might try adding code to your macro to delete the formula once the sheet
is named. Also add code to not rename the sheet if B7 is blank. HTH Otto
"D" wrote in message
...
Gary DK very kindly provided a solution for naming tabs from the contents
of
a cell on a worksheet. A further problem has arisen:

The contents of cell B7 on all 125 sheets provides the name for the sheet
tab. Cell B7 gets its information from a separate master sheet.

When I sort the master sheet (because new entries have been added at the
bottom and need to be arranged according to a ref. code) I get an error
message: Runtime error 1004 Cannot rename a sheet to the same name as
another
sheet, a referenced object library or a workbook referenced by Visual
Basic.

this is the code:

Option Explicit
Private shname As String

Private Sub Worksheet_Calculate()
If Range("B7").Value < shname Then
shname = [b7].Value
End If
Me.Name = shname
End Sub


Any ideas?