Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel: Selecting renaming current sheet in a macro.

Status
Not open for further replies.

fiel

Programmer
Jun 3, 2007
96
US
I have set a marco to rename a sheet based on the number entered in a cell, my code is as follows:

Function RenameSheet(place As Integer)

' What needs to go in place of "Me"
' In order to select the current sheet?
Sheets("Me").Select
Sheets("Me").Name = "MCC " & place

End Function

I jsut want to rename the sheet by adding a number at the end, any ideas on how to select only the current sheet that the macro is in?
 
Please create a new thread for this VBA/Macro-specific question in forum707

[tt]_____
[blue]-John[/blue][/tt]
[tab][red]The plural of anecdote is not data[/red]

Help us help you. Please read FAQ 181-2886 before posting.
 




Hi,

This cannot be a Sheet Function. Run as a Sub Procedure...
Code:
Sum RenameSheet()

' assuming that the number is in A1
ActiveSheet.Name = "MCC " & CStr(ActiveSheet.[A1].Value)

End Sub

Skip,
[sub]
[glasses] To be safe on the [red]FOURTH[/red],
Don't take a [red]FIFTH[/red] on the [red]THIRD[/red]
Or you might not come [red]FORTH[/red] on the [red]FIFTH[/red]
[red][highlight blue]FORTH[/highlight][/red][white][highlight red]WITH[/highlight][/white] [tongue][/sub]
 
Wouldn't I need a function if I wanted to monitor A1 continuously? Or is there a way so that as a sub A1 is always being monitored?
 




You'd have to use the worksheet_change event. Please post further VBA questions in Forum707.

Skip,
[sub]
[glasses] To be safe on the [red]FOURTH[/red],
Don't take a [red]FIFTH[/red] on the [red]THIRD[/red]
Or you might not come [red]FORTH[/red] on the [red]FIFTH[/red]
[red][highlight blue]FORTH[/highlight][/red][white][highlight red]WITH[/highlight][/white] [tongue][/sub]
 
Ya, Skip mentioned that I should move my question to this forum. Although as for the worksheet_change event, how would I implement it?
 
Whoops, I didn't notice that you can set the property throught the toolbar above... Clumsy me.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top