Discussion Locked

Excel Macro help

0 helpful
3 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I need to create a macro to rename a worksheet. I need this macro to work on any worksheet. The problem I am having is that in VB it just selects the name of old worksheet and renames it to whatever I call it. If I run this on another spreadsheet, it doesn't work becuase the name of the worksheet is not sheet1. It will never be named the same.

Is there a way to write a macro that takes the active sheet and renames it or a way I can tell it "The first sheet"?

Thanks,

Nicole

3 replies

by firstpeter

Sub RenActiveSheet()
ActiveSheet.Name = "Test"
End Sub

-or-

Sub RenFirstSheet()
Worksheets(1).Name = "Test"
End Sub

You'll want to replace "Test" with the name you're after.

This discussion is closed to new replies.