Put this in the ThisWorkbook code module of your workbook:
Private Sub Workbook_SheetChange( _
ByVal Sh As Object, _
ByVal Target As Excel.Range)
Dim sSheetName As String
With Target
If Not Intersect(.Cells, Range("A1")) Is Nothing Then
sSheetName = Range("A1").Text
If Not sSheetName = vbNullString Then
On Error Resume Next
Sh.Name = sSheetName
On Error GoTo 0
If Not sSheetName = Sh.Name Then _
MsgBox "Invalid worksheet name in cell A1"
End If
End If
End With
End Sub
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.