Macro to print different parts of worksheet based on a cell value.

hezcal11

Board Regular
Joined
Jan 20, 2012
Messages
57
Hello,
Sub Macro2()
'
' Macro2 Macro
Range("AR10") = "ENSURE THERE IS ENOUGH PAPER."
'Application.Wait (Now + #12:02:00 AM#)
Dim x As Long
For x = 1 To Range("EG1:EG131").Rows.Count
If Range("EG1:EG131").Cells(x, 1) <> "" Then
If Range("EG1:EG131").Cells(x, 1) = "N" Then
Range("D7") = Range("EE1").Cells(x, 1)
Range("d4") = Range("EF1").Cells(x, 1)
ActiveSheet.PageSetup.PrintArea = "$A$1:$AE$75"
Application.Wait (Now + #12:00:01 AM#)

ElseIf Range("EG1:EG131").Cells(x, 1) = "M" Then
Range("AU7") = Range("EE1").Cells(x, 1)
Range("AU4") = Range("EF1").Cells(x, 1)
ActiveSheet.PageSetup.PrintArea = "$AR$1:$BV$75"
Application.Wait (Now + #12:00:01 AM#)

ElseIf Range("EG1:EG131").Cells(x, 1) = "KOS" Then
Range("CL7") = Range("EE1").Cells(x, 1)
Range("CL4") = Range("EF1").Cells(x, 1)
ActiveSheet.PageSetup.PrintArea = "$CI$1:$DM$75"
Application.Wait (Now + #12:00:01 AM#)
End If
Next x

End Sub

I have a sheet that basically has three columns with a location (EE), a name( EF) and a menu type (EG). The macro used to cycle through the list and and the location and name to each menu before printing it out. Before I had three separate worksheets, one for each type. I was trying to print all from the one sheet and just change the print area based on the type. The above macro was my attempt but always returns an error. Is there something I am doing wrong? Any help would be appreciated. Thank you.
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.

Forum statistics

Threads
1,223,894
Messages
6,175,254
Members
452,623
Latest member
Techenthusiast

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