Round(Sheet2.Cells(x, 14).Value, 2)
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
If Sheet2.Cells(x, 8).Value <> 0 Then
y = x - 3
With Sheets(y)
.PageSetup.PrintArea = "$B$2:$F$21"
.PrintOut copies:=1
End With
End If
Sub test()
Dim wkb As Workbook
Dim wksNew As Worksheet
Dim outCursor As Range
Set wkb = ThisWorkbook
On Error Resume Next
Set wksNew = wkb.Worksheets("Log Sheet")
If Err.Number <> 0 Then
Set wksNew = wkb.Worksheets.Add(after:=wkb.Worksheets(wkb.Worksheets.Count))
wksNew.Name = "Log Sheet"
End If
On Error GoTo 0
wksNew.Cells.Clear
Set outCursor = wksNew.Range("A1")
For x = 6 To 19
outCursor.Value = "BLOCK 1 Sheet2.Cells(" & x & ",8).Address is = " & Sheet2.Cells(x, 8).Address & " having value: " & Sheet2.Cells(x, 8).Value
Set outCursor = outCursor.Offset(1, 0)
If Sheet2.Cells(x, 8).Value <> 0 Then
y = x - 3
With Sheets(y)
.PageSetup.PrintArea = "$B$2:$F$21"
.PrintOut Copies:=1
End With
End If
Next x
For x = 6 To 19
outCursor.Value = "BLOCK 2 Sheet2.Cells(" & x & ",11).Address is = " & Sheet2.Cells(x, 11).Address & " having value: " & Sheet2.Cells(x, 11).Value
Set outCursor = outCursor.Offset(1, 0)
If Sheet2.Cells(x, 11).Value <> 0 Then
y = x - 3
With Sheets(y)
.PageSetup.PrintArea = "$I$2:$M$21"
.PrintOut Copies:=1
End With
End If
Next x
For x = 6 To 19
outCursor.Value = "BLOCK 3 Sheet2.Cells(" & x & ",14).Address is = " & Sheet2.Cells(x, 14).Address & " having value: " & Sheet2.Cells(x, 14).Value
Set outCursor = outCursor.Offset(1, 0)
If Sheet2.Cells(x, 14).Value <> 0 Then
y = x - 3
With Sheets(y)
.PageSetup.PrintArea = "$b$22:$f$41"
.PrintOut Copies:=1
End With
End If
Next x
For x = 26 To 39
outCursor.Value = "BLOCK 4 Sheet2.Cells(" & x & ",14).Address is = " & Sheet2.Cells(x, 14).Address & " having value: " & Sheet2.Cells(x, 14).Value
Set outCursor = outCursor.Offset(1, 0)
If Sheet2.Cells(x, 14).Value <> 0 Then
y = x - 23
With Sheets(y)
.PageSetup.PrintArea = "$I$22:$M$41"
.PrintOut Copies:=1
End With
End If
Next x
End Sub
Title | # Comments | Views | Activity |
---|---|---|---|
Conditional format Excel Cell | 3 | 14 | |
Excel 2016 - Dotted line appears, but it's not a page break | 14 | 29 | |
Excel - Macro hide columns not working | 4 | 18 | |
Excel | 6 | 16 |
Join the community of 500,000 technology professionals and ask your questions.
Connect with top rated Experts
11 Experts available now in Live!