So we created some code that will allow a user to enter multiple pages of data and then just click a print button to print the number of pages of data they have entered. However we are running into a problem where by if a user enters 300 rows of data, then deletes the last 100 lines, it is still printing 300 rows of data, rather than 200.
Any suggestions?
Code:
Sub LastRowInOneColumn()
If Range("C19") = "Enter any special posting instruction here." Then
Range("C19:I26").ClearContents
End If
Dim MySheet As Worksheet
Set MySheet = Worksheets("SIF Sheet")
With MySheet
Dim xFirstEmptyRow As Long
xFirstEmptyRow = .Cells(30, 1).End(xlDown).Row
'Application.Dialogs(xlDialogPrinterSetup).Show
Worksheets("SIF Sheet").PrintOut
End With
End Sub
Imagine instead of 30-32, rows of 30-300 filled out with sample data. Then rows 300 back to 200 deleted on purpose(say it wasnt needed). Its still printing up to row 300, instead of to row 200.
Update
I tried playing around with some other variations and came up with this but its throwing an error saying cannot use that command on overlapping selections:
Sub LastRowInOneColumn()
If Range("C19") = "Enter any special posting instruction here." Then
Range("C19:I26").ClearContents
End If
Dim MySheet As Worksheet
Set MySheet = Worksheets("SIF Sheet")
Rows("30:1058").Select
Selection.SpecialCells(xlCellTypeBlanks).Select
Selection.EntireRow.Delete
With MySheet
Dim xFirstEmptyRow As Long
xFirstEmptyRow = .Cells(30, 1).End(xlDown).Row
'Application.Dialogs(xlDialogPrinterSetup).Show
Worksheets("SIF Sheet").PrintOut
End With
End Sub