General discussion

Locked

Excel Macro help

By Nsohenick ·
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

This conversation is currently closed to new comments.

3 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

Excel Macro help

by FirstPeter In reply to Excel Macro help

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.

Collapse -

Excel Macro help

by Nsohenick In reply to Excel Macro help

Sweet!

Thanks!

Collapse -

Excel Macro help

by Nsohenick In reply to Excel Macro help

This question was closed by the author

Back to Software Forum
3 total posts (Page 1 of 1)  

Related Discussions

Related Forums