Johnny Thunder
Well-known Member
- Joined
- Apr 9, 2010
- Messages
- 693
- Office Version
- 2016
- Platform
- MacOS
Hi guys,
I am working on a project and found myself spinning in circles with this code. Hope someone can steer me in the right direction.
Background:I have a menu grid with the name of 4 sheets that a user can have added to a workbook based on "True" or "False" from a drop down next to the sheet name. I need to build a If statement that can dynamically add or not add the sheet based on the option the user selects.
Example:
Sheet1 = False
Sheet2 = True
Sheet3 = False
Sheet4 = False
Desired Output:Code would loop thru the if statements and see that Sheet2 is the only Sheet that needs to be added.
Format of what I need:
Sound about right?
I am working on a project and found myself spinning in circles with this code. Hope someone can steer me in the right direction.
Background:I have a menu grid with the name of 4 sheets that a user can have added to a workbook based on "True" or "False" from a drop down next to the sheet name. I need to build a If statement that can dynamically add or not add the sheet based on the option the user selects.
Example:
Sheet1 = False
Sheet2 = True
Sheet3 = False
Sheet4 = False
Desired Output:Code would loop thru the if statements and see that Sheet2 is the only Sheet that needs to be added.
Format of what I need:
Code:
Sub 4Statements ()
'Sheet1-sheet4 are named ranges I created to look for the true or false value next to the sheet name
If Range("sheet1").value = True then 'Do what you need to do to create the sheet
elseif
'Skip to the next sheet option
If Range("sheet2").value = True then 'Do what you need to do to create the sheet
elseif
If Range("sheet3").value = True then 'Do what you need to do to create the sheet
elseif
If Range("sheet4").value = True then 'Do what you need to do to create the sheet
elseif
'End if '(x4 I would assume?)
End Sub
Sound about right?