ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Excel print code modification (https://www.excelbanter.com/excel-programming/416264-excel-print-code-modification.html)

Chris

Excel print code modification
 
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


All times are GMT +1. The time now is 05:34 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com