Is it possible to print a named range of data excel

R

Rachel

Hi,

Is it possible to print a named range of data excel (the data is in a
hidden sheet)

My named ranges are "Filtered_Data" which is in the "Working" sheet
and "Data_Table" which is in a hidden sheet called "Data", depending
on what a listbox row source is I want to print one or these ranges to
a default printer. My code is below:

Private Sub cmd_print_Click()
Dim Response As VbMsgBoxResult
If ListBox2.RowSource = "Filtered_Data" Then
'code here to print "Filtered_Data" range
Else
Response = MsgBox("No data has been filtered, do you want to print
all data?", vbQuestion + vbYesNo)
If Response = vbNo Then Exit Sub
'code here to print "Data_Table" range
MsgBox "All data has been sent to the printer.", vbInformation
End If

End Sub

Any help would be greatly appreciated!

Rachel
 
S

Stefi

Private Sub cmd_print_Click()
Dim Response As VbMsgBoxResult
If ListBox2.RowSource = "Filtered_Data" Then
'code here to print "Filtered_Data" range
Range("Filtered_Data").PrintOut Copies:=1, Collate:=True
Else
Response = MsgBox("No data has been filtered, do you want to print
all data?", vbQuestion + vbYesNo)
If Response = vbNo Then Exit Sub
'code here to print "Data_Table" range
Sheets("Data").Visible = True
Range("Data_Table").PrintOut Copies:=1, Collate:=True
Sheets("Data").Visible = False
MsgBox "All data has been sent to the printer.", vbInformation
End If

End Sub

Regards,
Stefi
 

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