Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro to have user enter new worksheet name
Hello all
At the end of my macro, I want the user to rename the active worksheet. Is there some way I can do this in VBA. Failing that, how would I get a message box to appear reminding the user they need to change the worksheet name. Thank you in advance. MMH |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro to have user enter new worksheet name
One way:
Public Sub RenameSheet() Dim vNewName As Variant With ActiveSheet Do vNewName = Application.InputBox( _ Prompt:="Enter new worksheet name:", _ Title:="Rename Worksheet", _ Type:=2) If vNewName = False Then Exit Sub 'user cancelled If UCase(vNewName) = UCase(.Name) Then vNewName = "" ElseIf Len(Trim(vNewName)) 0 Then On Error Resume Next .Name = vNewName On Error GoTo 0 End If Loop Until .Name = vNewName End With End Sub In article , MMH wrote: At the end of my macro, I want the user to rename the active worksheet. Is there some way I can do this in VBA. Failing that, how would I get a message box to appear reminding the user they need to change the worksheet name. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro to have user enter new worksheet name
Thank you, that did exactly what I wanted.
MMH :) "JE McGimpsey" wrote: One way: Public Sub RenameSheet() Dim vNewName As Variant With ActiveSheet Do vNewName = Application.InputBox( _ Prompt:="Enter new worksheet name:", _ Title:="Rename Worksheet", _ Type:=2) If vNewName = False Then Exit Sub 'user cancelled If UCase(vNewName) = UCase(.Name) Then vNewName = "" ElseIf Len(Trim(vNewName)) 0 Then On Error Resume Next .Name = vNewName On Error GoTo 0 End If Loop Until .Name = vNewName End With End Sub In article , MMH wrote: At the end of my macro, I want the user to rename the active worksheet. Is there some way I can do this in VBA. Failing that, how would I get a message box to appear reminding the user they need to change the worksheet name. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Macro needed to pull data from one worksheet and enter it in anoth | Excel Discussion (Misc queries) | |||
Macro to select cells in column enter data then press enter | New Users to Excel | |||
enter user in cell | Excel Worksheet Functions | |||
Using user defined workbook name in macro worksheet functions | Excel Programming | |||
Prompt User to Enter Data with a macro | Excel Programming |