Code is not working....please take a look!!!

  • Thread starter Thread starter tratliff
  • Start date Start date
T

tratliff

I'm having some problems with my code.

Here is what is NOT working:

I'm not getting Sheet2 thru Sheet5...it is only printing Sheet1...an
suggestions as to why??

Also, my message box is not popping up if the cell is blank???



If Range("l12") = 2 Then
Sheets(Array("sheet1", "sheet2", "sheet3", "sheet4", "sheet5"
"sheet6")).Select
Range("ac1:ax79").PrintOut
If Range("l12") = 3 Then
Sheets(Array("lays", "bistro", "kettle", "lay
lights", "stax", "ruffles")).Select
Range("ay1:bt79").PrintOut
If Range("L12") = 4 Then
Sheets(Array("lays", "bistro"
"kettle", "lays lights", "stax", "ruffles")).Select
Range("bu1:cw79").Print
If Range("l12") = " " Then
MsgBox ("Please enter quarte
you wish to print in cell L12 on the Menu tab")
End If
End If
End If
End I
 
If Range("l12") = 2 Then
Sheets(Array("sheet1", "sheet2", "sheet3", "sheet4", "sheet5"
"sheet6")).Select
Range("ac1:ax79").PrintOut
End If

If Range("l12") = 3 Then
Sheets(Array("lays", "bistro", "kettle", "lays lights", "stax"
"ruffles")).Select
Range("ay1:bt79").PrintOut
End If

If Range("L12") = 4 Then
Sheets(Array("lays", "bistro", "kettle", "lays lights", "stax"
"ruffles")).Select
Range("bu1:cw79").Print
End If

If Range("l12") = "" Then
MsgBox ("Please enter quarter you wish to print in cell L12 on the Men
tab")
End I
 
Better yet...


Select Case Range("l12")
Case Is = 2
Sheets(Array("sheet1", "sheet2", "sheet3", "sheet4", "sheet5"
"sheet6")).Select
Range("ac1:ax79").PrintOut
Case Is = 3
Sheets(Array("lays", "bistro", "kettle", "lays lights", "stax"
"ruffles")).Select
Range("ay1:bt79").PrintOut
Case Is = 4
Sheets(Array("lays", "bistro", "kettle", "lays lights", "stax"
"ruffles")).Select
Range("bu1:cw79").Print
Case Is = ""
MsgBox ("Please enter quarter you wish to print in cell L12 on th
Menu tab")
End Selec
 
Try this...

Select Case Range("l12")
Case Is = 2
Sheets(Array("sheet1", "sheet2", "sheet3", "sheet4", "sheet5"
"sheet6")).Select
Selection.Range("ac1:ax79").PrintOut
Case Is = 3
Sheets(Array("lays", "bistro", "kettle", "lays lights", "stax"
"ruffles")).Select
Selection.Range("ay1:bt79").PrintOut
Case Is = 4
Sheets(Array("lays", "bistro", "kettle", "lays lights", "stax"
"ruffles")).Select
Selection.Range("bu1:cw79").Print
Case Is = ""
MsgBox ("Please enter quarter you wish to print in cell L12 on the Men
tab")
End Selec
 
How about:

Sub test()

Dim sht As Worksheet

Select Case Worksheets("Menu").Range("L12").Value
Case 2
For Each sht In Sheets(Array("sheet1", "sheet2", "sheet3", "sheet4",
"sheet5", "sheet6"))
sht.Range("ac1:ax79").PrintOut
Next sht
Case 3
For Each sht In Sheets(Array("lays", "bistro", "kettle",
"layslights", "stax", "ruffles"))
sht.Range("ay1:bt79").PrintOut
Next sht
Case 4
For Each sht In Sheets(Array("lays", "bistro", "kettle", "lays
lights", "stax", "ruffles"))
sht.Range("bu1:cw79").PrintOut
Next sht
Case Else
MsgBox ("Please enter quarter you wish to print in cell L12 on the
Menu tab")
End Select

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top