Rename a worksheet with a new name

DLRosen46

New Member
Joined
Mar 31, 2016
Messages
2
I created a macro to format a daily report. The file, and hence, the worksheet will always be named "ACK_#", where # is the day of the month (ex. ACK_23). I want to create a copy of the worksheet named, "ACK_#" and rename it "Summary." My problem is that I created the macro from a file/worksheet named "ACK_23" but I need the macro to work for any day.

Here is the code at issue:

Sub ACK_for_ADV()

' ACK_for_ADV Macro
...
Sheets("ACK_23").Select
Sheets("ACK_23").Copy Before:=Sheets(1)
Sheets("ACK_23 (2)").Select
Sheets("ACK_23 (2)").Name = "Summary"

I basically want to replace "ACK_23" with a wildcard or variable, but I'm not sure how to do this.
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Dim s As String

s = ...
Sheets("ACK_" & s)

you just got to get the right number wherever it is
 
Upvote 0
Perhaps.
Code:
Sub ACK_for_ADV()

' ACK_for_ADV Macro
...
Sheets("ACK_" & Day(Date())).Copy Before:=Sheets(1)
Sheets(1).Name = "Summary"
 
Upvote 0

Forum statistics

Threads
1,223,961
Messages
6,175,651
Members
452,664
Latest member
alpserbetli

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top