VBA help - Copy sheet into new worksheet if criteria is met

TMcKenzie

New Member
Joined
Jun 15, 2021
Messages
3
Hi,

I am trying to create a macro that copies a specific sheet into a new workbook depending on a dropdown list in cell O2 containing specific criteria.

I have 6 worksheets called 'SD Upload 1', 'SD Upload 2', 'SD Upload 3', 'SD Upload 4', 'SD Upload 5', 'SD Upload 6' & cell O2 contains a dropdown list of Phase 1-6 so would like these to marry up with the 'upload' tabs.

Any help would be appreciated.

Thanks,

Taylor
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Taylor,

The following might get you started...

VBA Code:
Sub Sheet_SaveAs()
Dim str As String
Dim wb As Workbook

Application.ScreenUpdating = False
str = "SD Upload " & Right(Sheets("Sheet1").Range("O2"), 1) '<----Change Sheet1 to the name of the sheet with the dropdown list
Sheets(str).Copy
Set wb = ActiveWorkbook
With wb
    .SaveAs ThisWorkbook.Path & "\" & str & " " & Format(Date, "yyyymmdd")
    .Close False
End With
Application.ScreenUpdating = True
End Sub

Cheers,

Tony
 
Upvote 0

Forum statistics

Threads
1,215,731
Messages
6,126,537
Members
449,316
Latest member
sravya

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