View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Ron de Bruin Ron de Bruin is offline
external usenet poster
 
Posts: 11,123
Default printing a range that changes all the time

Try this Pierre

Sub test()
Dim rngprint As Range
Dim lr As Long
Sheets("Outputdlnrs").Select
lr = Range("B" & Rows.Count).End(xlUp).Row
Set rngprint = Range("A1:M" & lr)
rngprint.PrintPreview
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Pierre via OfficeKB.com" <u13950@uwe wrote in message news:566bc8945ed14@uwe...
Hi experts,

I have data starting from A1 to M...
I would like to count the rows to print based on the input in column B !!!

I have the following code for printing a range.

Dim rngprint As Range
Sheets("Outputdlnrs").Select
Set rngprint = Range("A1", Range("A1").End(xlDown).Address)
ActiveSheet.PageSetup.PrintArea = rngprint.Address
Selection.PrintPreview

This does not work because only A1 is selected each time.

Does anybody have the right formula ?

Thanks,
Pierre


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200510/1