I'm quite new to VBAs/Macros so assuming this is an easy fix I'm missing.
I am looking to automate a process, which involves opening a workbook, filtering a sheet based on value "x", copy the sheet, paste into original workbook, then repeat this process with 4-5 different sheets. I currently have 4-5 different subs written, all which work, but had to be done manually changing "PB NY - Private" to "y" then "z", etc.
Am I correct in assuming there should be someway to have this process just be one sub, and possibly be able to have a variable reference to a cell in my original workbook? So if that cell says "PB NY - Private", the sub would run based on that, if "y" based on that, etc?
This is a piece of one sub, where "PB NY - Private" is the piece I would like to have based on a cell value (X, Y, or Z)
You can change your hardcoded Criteria1
to the reference of a cell. Since code opens other workbooks in the reference fully qualify the workbook and worksheet name.
ActiveSheet.Range("$A$1:$AB$1236").AutoFilter Field:=1, Criteria1:= _
Workbooks("Workbook_name").WorkSheets("Sheet_name").Range("address")
This process can be applied to the sheet names too.
If you add a command button to your sheet, the sub can be called with it.