0

I am trying to record a Macro to print selected cells then return the worksheet to its original format. I am hiding columns B through H, printing A7:I68. While recording the Macro the print comes out correct. Once saved it only prints column A7:A68, does not include column I.

ActiveSheet.Unprotect
Columns("B:H").Select
Selection.EntireColumn.Hidden = True
Range("A7:I68").Select
ActiveSheet.PageSetup.PrintArea = "$A$7:$I$68"
Selection.PrintOut Copies:=1, Collate:=True
Columns("A:I").Select
Selection.EntireColumn.Hidden = False
ActiveWindow.SmallScroll Down:=-72
Range("A10").Select
ActiveSheet.Protect DrawingObjects:=False, Contents:=True, Scenarios:= _
    False

Any Suggestions?

3
  • Edit the question and insert your Macro
    – yass
    Mar 30, 2017 at 16:49
  • Go into the macro, and press F8. See what happens, and press F8 and see what happens, step by step. Maybe it's not hiding the columns properly. Maybe it's not selecting the print area - stepping into a macro is a decent troubleshooting step.
    – Selkie
    Mar 30, 2017 at 19:57
  • Selkie, Thank you for your suggestion, I tried it but got the same result. The print area is set up correct in the macro but the output is still only column A. ActiveSheet.PageSetup.PrintArea = "$A$7:$I$68". Any other ideas?
    – Tina Stone
    Mar 31, 2017 at 13:24

1 Answer 1

0

Tina I would like to suggest VBA code to print Not one but Multiple Selections,, this will copy range to print make sheet paste there, show Preview, Print & finally delete that sheet.

Sub Print_MultiSelection()

Dim rng As Range, ws As Worksheet, rngArea As Range

Set rng = Selection

Set ws = Worksheets.Add(After:=Sheets(Sheets.Count))

For Each rngArea In rng.Areas rngArea.Copy Destination:=ws.Range(rngArea.Address)

ws.Range(rngArea.Address).Value = rngArea.Value

Next 

rngArea ws.PrintPreview

ws.PrintOut Copies:=1, Collate:=True, IgnorePrintAreas:= False

Application.DisplayAlerts = False

ws.Delete Application.DisplayAlerts = True

rng.Parent.Activate

End Sub

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.