The first two arguments for PrintOut are [From] and [To]
So your code could use
Code:Sub PrintForms() Dim StartRow As Integer Dim EndRow As Integer Dim Msg As String Dim i As Integer Dim lngFrom As Long Dim lngTo As Long lngFrom = 6 lngTo = 12 Sheets("Resume").Activate StartRow = Range("StartRow") EndRow = Range("EndRow") If StartRow > EndRow Then Msg = "ERROR" & vbCrLf & "The starting row must be less than the ending row!" MsgBox Msg, vbCritical, APPNAME End If For i = StartRow To EndRow Range("RowIndex") = i If Range("Preview") Then ActiveSheet.PrintPreview Else ActiveSheet.PrintOut lngFrom, lngTo 'But to make it more idiot proof, you could use the following 'ActiveSheet.PrintOut Application.Min(Sheets.Count, lngFrom), Application.Min(Sheets.Count, lngTo) End If Next i End Sub




Reply With Quote
Bookmarks