Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Set Print Area after paste 1

Status
Not open for further replies.

SILLEYJ

MIS
Jan 25, 2000
43
0
0
GB
I am pasting data from a web page using a macro, after the data is pasted how can I set the print area to only include the pasted information. The information is still active but am having problems getting the macro to only use the active cells for the print area.

Thanks
Jeff
 
Jeff
What code do you have so far?
What range is selected after paste (there's a difference between selected and active as you can only ever have one active cell)?

Wouls
Code:
ActiveSheet.PageSetup.PrintArea = Selection.Address
not work?

Happy Friday

;-)
If a man says something and there are no women there to hear him, is he still wrong? [ponder]
How do I get the best answers?
 
Excellent, thanks for that, works like a charm.

Jeff

Enjoy the weekend.

 
How about if I wanted to select from column 6 to column BC but only the rows with data in them as the number of rows changes daily?

Jeff
 
How about if I wanted to select from column C to column BC but only the rows with data in them as the number of rows changes daily?

Jeff
 
Firstly find out what the last data row is. There are a couple of FAQs that could help you with this or you could use the End method of the Range object,
eg range("A65526").end(xlup).row will give you the last used row in column A.
Assign this number to a variable (eg lRow) then use
ActiveSheet.PageSetup.PrintArea = range("C1:BC"&lRow)

Happy Friday

;-)
If a man says something and there are no women there to hear him, is he still wrong? [ponder]
How do I get the best answers?
 
Thanks Loomah

Just what I needed when I needed it. Got tangled up with CurrentRegion.

Dave
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top