If Checkbox1 = True Add New Sheet named "xyz"

Jingles3X

New Member
Joined
Oct 20, 2021
Messages
34
Office Version
  1. 2013
Platform
  1. Windows
Hi. I have a userform I create that has 15 checkboxes.
I am trying to accomplish "if checkbox 1 is true, then create a new sheet named "xyz" for each checkbox.

Here is the code I have that doesn't seem to work. I have tried to modify but no success:

VBA Code:
Sub Create_Pages()
dim wb = this workbook
with wb
     If CheckBox1.Value = True Then
         sheets.add "xyz"
     End If
end with

End Sub

I will add for each checkbox on my userform.

Can anyone tell me what I am doing wrong?
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
How about
VBA Code:
Sub Create_Pages()


With ThisWorkbook
     If CheckBox1.Value = True Then
         .Sheets.Add.Name = "xyz"
     End If
End With

End Sub
 
Upvote 0

Forum statistics

Threads
1,215,756
Messages
6,126,692
Members
449,330
Latest member
ThatGuyCap

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