C
CR
Excel 2003
I have a spread sheet that I paste an entire table into from a webpage each
week.
Range A6:V44
The information starts in A6:A44 and expands one column each week except for
the week numbers they are in B7:V7 each week
I am trying to set the print area using .CurrentRegion.Select
I don't want to print out the entire Range only the columns that have the
information in them.
To use the CurrentRegion.Select, I need to get rid of the week numbers while
I select the Print Area and then
paste them back after the print area is selected.
If I manually remove the weeks and run this without the copy, clear, paste
it works fine, but with it, the thing stops on
ActiveSheet.Paste
Any ideas why? Or a better way to do this?
Also why doesn't Range("B7:V7").Cut work?
Private Sub CommandButton2_Click()
'Set Print area.
Range("B7:V7").Select
Selection.Copy
Selection.Clear
ActiveSheet.Range("A6").CurrentRegion.Select
ActiveSheet.PageSetup.PrintArea = Selection.Address
Range("B7:V7").Select
ActiveSheet.Paste '........Stops running here, Run-time error '1004'
Application-defined or object-defined error
Sheet2.PrintPreview
End Sub
Thanks
CR
I have a spread sheet that I paste an entire table into from a webpage each
week.
Range A6:V44
The information starts in A6:A44 and expands one column each week except for
the week numbers they are in B7:V7 each week
I am trying to set the print area using .CurrentRegion.Select
I don't want to print out the entire Range only the columns that have the
information in them.
To use the CurrentRegion.Select, I need to get rid of the week numbers while
I select the Print Area and then
paste them back after the print area is selected.
If I manually remove the weeks and run this without the copy, clear, paste
it works fine, but with it, the thing stops on
ActiveSheet.Paste
Any ideas why? Or a better way to do this?
Also why doesn't Range("B7:V7").Cut work?
Private Sub CommandButton2_Click()
'Set Print area.
Range("B7:V7").Select
Selection.Copy
Selection.Clear
ActiveSheet.Range("A6").CurrentRegion.Select
ActiveSheet.PageSetup.PrintArea = Selection.Address
Range("B7:V7").Select
ActiveSheet.Paste '........Stops running here, Run-time error '1004'
Application-defined or object-defined error
Sheet2.PrintPreview
End Sub
Thanks
CR