Selecting a variable print area in a macro

S

Surrealest

I need to be able to select a variable print area in a macro.
every time I use the macro I need to be able to highlight a different range
for printing. When recording the macro I entered in a range ("B5:G23") but
now I need that to be a selectable variable before I print.
 
D

Dave Peterson

Dim myRng as range

set myRng = nothing
on error resume next
set myrng = application.inputbox(Prompt:="Select a range", type:=8)
on error goto 0

if myrng is nothing then
msgbox "Try again later" 'user hit cancel
else
myrng.printout
end if
 
S

Surrealest

That worked wonders. Thank you very much

Dave Peterson said:
Dim myRng as range

set myRng = nothing
on error resume next
set myrng = application.inputbox(Prompt:="Select a range", type:=8)
on error goto 0

if myrng is nothing then
msgbox "Try again later" 'user hit cancel
else
myrng.printout
end if
 

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