Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
MMH MMH is offline
external usenet poster
 
Posts: 14
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default 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   Report Post  
Posted to microsoft.public.excel.programming
MMH MMH is offline
external usenet poster
 
Posts: 14
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro needed to pull data from one worksheet and enter it in anoth bigproblem Excel Discussion (Misc queries) 2 November 18th 08 02:14 PM
Macro to select cells in column enter data then press enter NP New Users to Excel 1 February 20th 08 04:21 PM
enter user in cell pbs Excel Worksheet Functions 1 July 30th 07 11:26 PM
Using user defined workbook name in macro worksheet functions Mark Excel Programming 0 April 6th 05 06:11 PM
Prompt User to Enter Data with a macro Rebecca[_6_] Excel Programming 2 August 23rd 03 03:55 PM


All times are GMT +1. The time now is 05:52 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"