IF statements and Macros

rmcbreen

New Member
Joined
Oct 22, 2002
Messages
26
I am not sure that this is possible, but I want to write an if statemnet that will run a macro to print a page if a certain box is checked.

Example: If a box is checked to run a certain test, I want an IF statement that recognizes that the box is checked, and will print the test pages(seperate workbook) when I print the worksheet with the checked box.

Any ideas?

Actually, I am not sure that I would need to use IF statements, if there is a way to do this without IF's, that would be great too.

Thanks

Ryan
This message was edited by rmcbreen on 2002-10-23 18:09
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
59,500
Office Version
  1. 365
Platform
  1. Windows
Right click on your check box, click on "Assign Macros" and click on "New". Then in the VBA editor, enter the following code

Sub CheckBox1_Click()

If ActiveSheet.CheckBoxes(Application.Caller).Value = xlOn Then
'(enter code here for printing worksheet)
End If

End Sub

If you do not know VBA well, you can turn on the macro recorder, open the workbook you want to print, print, and then stop the recorder. Then in VBA editor, copy the code you just recorded into the macro above.

Hope this helps.
 

majtnet

New Member
Joined
Apr 13, 2005
Messages
12
Bump: Macro If statements

I got the if statement, what do you put next to skip to next statement when the first criteria isn't met?
 

Forum statistics

Threads
1,144,363
Messages
5,723,919
Members
422,527
Latest member
JayTheKaz

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