Excel print code modification

C

Chris

I need to somehow change the below code so that it only prints data
that is visible after it's filtered on the data sheet. Is this
possible?

Public Const APPNAME As String = "Elephants R Us"
Option Explicit

Sub PrintForms()
Dim StartRow As Integer
Dim EndRow As Integer
Dim Msg As String
Dim i As Integer

Sheets("Form").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
End If
Next i
End Sub

Sub EditData()
Worksheets("Data").Activate
Range("A1").Select
End Sub

Sub ReturnToForm()
Worksheets("Form").Activate
Range("RowIndex").Select
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top