Happy Friday Excel Wizards!
There are similar posts on the boards but I haven't found one that quite gets me to where I need to be and I am getting desperate! What I want to do is have a userform that includes checkboxes and upon selection of the checkbox, it will print the quote for the particular fruit or fruits selected. The Quote template is on one tab in the workbook where cells A1:S60 contain the quote for Oranges, cells A68:S128 contain the quote for Apples, cells A129:S189 contain the quote for Watermellon, etc. going down for all six fruits...
What I want my code to do is to set the print range based on the fruits selected so if the user picks Oranges and Watermelons, it won't set the print area for Apples. Each quote is a named range so cells A1:S60 is named Quote_Oranges_Print_Area".
The following code works but as you can probably guess where I am going, there are 36 different combinations of print areas based on whether the user selects one fruit or a combination. I do not want to enter in all of the combinations nor put a lookup table in the worksheet (matrix based on true/false values) and instead am looking for code to set the print area.
Any ideas???? Thank you beforehand
There are similar posts on the boards but I haven't found one that quite gets me to where I need to be and I am getting desperate! What I want to do is have a userform that includes checkboxes and upon selection of the checkbox, it will print the quote for the particular fruit or fruits selected. The Quote template is on one tab in the workbook where cells A1:S60 contain the quote for Oranges, cells A68:S128 contain the quote for Apples, cells A129:S189 contain the quote for Watermellon, etc. going down for all six fruits...
What I want my code to do is to set the print range based on the fruits selected so if the user picks Oranges and Watermelons, it won't set the print area for Apples. Each quote is a named range so cells A1:S60 is named Quote_Oranges_Print_Area".
The following code works but as you can probably guess where I am going, there are 36 different combinations of print areas based on whether the user selects one fruit or a combination. I do not want to enter in all of the combinations nor put a lookup table in the worksheet (matrix based on true/false values) and instead am looking for code to set the print area.
Code:
Private Sub cmdTestPrintArea_Button_Click()
'************* put in the code here to select the print areas for the quotes ****************
If frmQuote.chkQuoteOranges.Value = True And frmQuote.chkQuoteApples.Value = False And _
frmQuote.chkQuoteWatermelon.Value = False And frmQuote.chkQuoteCherries.Value = True And _
frmQuote.chkQuotePapaya.Value = True And frmQuote.chkQuoteGrapes.Value = False Then
ActiveSheet.PageSetup.PrintArea = "Quote_Oranges_Print_Area,Quote_Cherries_Print_Area,Quote_Papaya_Print_Area,Quote_Grapes_Print_Area,"
End Sub
*** I am thinking I could do this with either a select case or an If Then such as the code below but it doesn't work
If frmQuote.chkQuoteOranges.Value = True Then
strOrangePrintArea = ThisWorkbook.Names("Quote_Oranges_Print_Area") Else
""
End If
If frmQuote.chkQuoteApples.Value = True Then
strApplesPrintArea = ThisWorkbook.Names("Quote_Apples_Print_Area") Else
""
End If
If frmQuote.chkQuoteWatermelon.Value = True Then
strWatermelonPrintArea = ThisWorkbook.Names("Quote_Watermelon_Print_Area") Else
""
End If
'***** and the same for the rest of the fruit ******
'***** then *****
ActiveSheet.PageSetup.PrintArea = strOrangePrintArea & strApplesPrintArea & strWatermelonPrintArea
Any ideas???? Thank you beforehand
Last edited by a moderator: