Hello!
I'm a nuby in vba code.... i have searched in forum but i can find what i need...
Let's say i have a userform with 20 checkbox, when one or several are true i want to print a area on sheet1.
Data on sheet1 change with the value of range ("AF2") in same sheet.
Range ("AF2") value came from checkbox (1,2,3...,20)
I have manage this code, it only print sheet with the last value of range ("AF2"):
Private Sub CommandButton1_Click()
Dim MyRange As Range
Set MyRange = Range("A1:z49")
With ActiveSheet.PageSetup
.TopMargin = 0.12 * 72
.LeftMargin = 0.25 * 72
.BottomMargin = 0.14 * 72
.RightMargin = 0.21 * 72
.HeaderMargin = 0.07 * 72
.FooterMargin = 0.05 * 72
.PrintArea = MyRange.Address
End With
If CheckBox1.Value = True Then Range("AF2") = 1
ActiveWindow.SelectedSheets.PrintOut Copies:=1
If CheckBox2.Value = True Then Range("AF2") = 2
ActiveWindow.SelectedSheets.PrintOut Copies:=1
.....
End Sub
Thanks a lot
I'm a nuby in vba code.... i have searched in forum but i can find what i need...
Let's say i have a userform with 20 checkbox, when one or several are true i want to print a area on sheet1.
Data on sheet1 change with the value of range ("AF2") in same sheet.
Range ("AF2") value came from checkbox (1,2,3...,20)
I have manage this code, it only print sheet with the last value of range ("AF2"):
Private Sub CommandButton1_Click()
Dim MyRange As Range
Set MyRange = Range("A1:z49")
With ActiveSheet.PageSetup
.TopMargin = 0.12 * 72
.LeftMargin = 0.25 * 72
.BottomMargin = 0.14 * 72
.RightMargin = 0.21 * 72
.HeaderMargin = 0.07 * 72
.FooterMargin = 0.05 * 72
.PrintArea = MyRange.Address
End With
If CheckBox1.Value = True Then Range("AF2") = 1
ActiveWindow.SelectedSheets.PrintOut Copies:=1
If CheckBox2.Value = True Then Range("AF2") = 2
ActiveWindow.SelectedSheets.PrintOut Copies:=1
.....
End Sub
Thanks a lot