vba code for printing command button / listbox

  • Thread starter Thread starter bkey01
  • Start date Start date
B

bkey01

I have an Excel workbook containing over 40 sheets with each having a
least 7 pages setup to print out in the page setup area.

I have multiple listboxes setup to goto specific cell that contain th
start of each page.

I am trying to write a code in vb using a listbox and command button t
print certain pages from different sheets. i.e. On sheet 1, I want t
print the information that starts in cell a50 and ends in aa110 an
then on sheet2, I want to print the information that starts in cell a1
and ends in aa32 and so on.

Example of code I have tried:
if listbox1.selected(0) then goto errhandler1
listbos1.selected(0) = false

errhandler1:
sheet1.range(a50:aa110).printout
end sub

THIS DID NOT WORK FOR ME!

Can someone please help me with this.

Thanks in advance
 
Hi

Try this

I use the DblClick event of the listbox in this example
Change MsgBox "your print code"
to your printcode line

Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
If Me.ListBox1.Selected(0) = True Then MsgBox "your print code"
If Me.ListBox1.Selected(1) = True Then MsgBox "your other print code"
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

Back
Top