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

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
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,491
Messages
6,125,110
Members
449,205
Latest member
ralemanygarcia

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