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
If you are experiencing a similar issue, please ask a related question
Title | # Comments | Views | Activity |
---|---|---|---|
What is format f12.8 for a CSV file | 6 | 41 | |
FormulaArray VBA Issue | 6 | 17 | |
Excel VBA - reference a textbox on a userform using a variable dynamically | 2 | 25 | |
NEED TO UPDATE DATA IN EXCEL | 18 | 32 |
Join the community of 500,000 technology professionals and ask your questions.
Connect with top rated Experts
13 Experts available now in Live!