Setting a variable print area

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to write a macro that will set a print area within a sheet. I have tried to record a macro to set it to a selection using shift, control and the arrow keys (as in how you highlight a range of cells), but when I set the print area it sets it to the actual cells, so if the selection changes, the print area won't

Is there any way of doing this, bearing in mind that the selection needed to print will change each time?
 
Below is a copy of what I have so far

Sub PrintDailyList(

Range("A1:A2").Selec
Range(Selection, Selection.End(xlToRight)).Selec
Range(Selection, Selection.End(xlDown)).Selec
Range(Selection, Selection.End(xlDown)).Selec
ActiveSheet.PageSetup.PrintArea = "$A$1:$D$250
With ActiveSheet.PageSetu
.LeftHeader = "
.CenterHeader = "
.RightHeader = "
.LeftFooter = "
.CenterFooter = "
.RightFooter = "
.LeftMargin = Application.InchesToPoints(0.75
.RightMargin = Application.InchesToPoints(0.75
.TopMargin = Application.InchesToPoints(1
.BottomMargin = Application.InchesToPoints(1
.HeaderMargin = Application.InchesToPoints(0.5
.FooterMargin = Application.InchesToPoints(0.5
.PrintHeadings = Fals
.PrintGridlines = Fals
.PrintComments = xlPrintNoComment
.PrintQuality = 60
.CenterHorizontally = Fals
.CenterVertically = Fals
.Orientation = xlPortrai
.Draft = Fals
.PaperSize = xlPaperA
.FirstPageNumber = xlAutomati
.Order = xlDownThenOve
.BlackAndWhite = Fals
.Zoom = 10
End Wit
'ActiveWindow.SelectedSheets.PrintPrevie
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=Tru

----- Frank Kabel wrote: ----

H
you may post your existing code :-

-
Regard
Frank Kabe
Frankfurt, German


cdb wrote
 
Hi
try the following to always print your current selection:

Sub PrintDailyList()
dim rng as range
set rng = selection
With ActiveSheet.PageSetup
.PrintArea = rng.address
end with
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
end sub
 
Cheers, I'll give that a go

----- Frank Kabel wrote: ----

H
try the following to always print your current selection

Sub PrintDailyList(
dim rng as rang
set rng = selectio
With ActiveSheet.PageSetu
.PrintArea = rng.addres
end wit
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=Tru
end su


-
Regard
Frank Kabe
Frankfurt, German


cdb wrote
 
Back
Top