VBA for copying a worsheet then opening new worksheet at a specific cell

GedSalter

Board Regular
Joined
Apr 24, 2019
Messages
80
I have a number in Cell M4. I am copying the sheet and renaming it to the value in M4. I also want to open the copy and open it at Cell A1. I have this code so far but unsure about the rest.


Dim ws As Worksheet
Set wh = Worksheets(ActiveSheet.Name)
ActiveSheet.Copy After:=Worksheets(Sheets.Count)
If wh.Range("M4").Value <> "" Then
ActiveSheet.Name = wh.Range("M4").Value
End If
wh.Activate
Range ("A1")

End Sub


Hope you can help.

regards Ged
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Something like:
Code:
Sub Add_Sheet()

Dim ws As Worksheet
Dim wh As Worksheet
 Set ws = Worksheets(ActiveSheet.Name)
 ActiveSheet.Copy After:=Worksheets(Sheets.Count)
 Set wh = Worksheets(Sheets.Count)
 If ws.Range("M4").Value <> "" Then
 wh.Name = ws.Range("M4").Value
 End If
 wh.Activate
 Range("A1").Select
 End Sub
 
Upvote 0

Forum statistics

Threads
1,214,887
Messages
6,122,095
Members
449,064
Latest member
Danger_SF

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