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

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.

tonyyy

Well-known Member
Joined
Jun 24, 2015
Messages
1,771
Office Version
  1. 2010
Platform
  1. Windows
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
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,151,842
Messages
5,766,738
Members
425,376
Latest member
Bradleyckx

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
Top