Solved

# Excel print range

Posted on 2012-04-13

I have a macro that I use to print a range of cells. If it does not = 0 then it prints. It worked until I tried the same macro in the Excel 2010 - it works except that it prints all - even if the sum is zero.

Any help is appreciated.

For x = 6 To 19

If Sheet2.Cells(x, 8).Value <> 0 Then

y = x - 3

Sheets(y).Select

ActiveSheet.PageSetup.PrintArea = "$B$2:$F$21"

ActiveWindow.SelectedSheets.PrintOut Copies:=1

End If

Next x

For x = 6 To 19

If Sheet2.Cells(x, 11).Value <> 0 Then

y = x - 3

Sheets(y).Select

ActiveSheet.PageSetup.PrintArea = "$I$2:$M$21"

ActiveWindow.SelectedSheets.PrintOut Copies:=1

End If

Next x

For x = 6 To 19

If Sheet2.Cells(x, 14).Value <> 0 Then

y = x - 3

Sheets(y).Select

ActiveSheet.PageSetup.PrintArea = "$b$22:$f$41"

ActiveWindow.SelectedSheets.PrintOut Copies:=1

End If

Next x

For x = 26 To 39

If Sheet2.Cells(x, 14).Value <> 0 Then

y = x - 23

Sheets(y).Select

ActiveSheet.PageSetup.PrintArea = "$I$22:$M$41"

ActiveWindow.SelectedSheets.PrintOut Copies:=1

End If

Next x

End Sub