Macro for selectiong rows to print

ARIZONA3433

Board Regular
Joined
Dec 8, 2005
Messages
56
Hello all,

Looking through this Qand A board for the last two cay has made my eyes cross. Since I am just learning to write code in vba I have appreciated the help I have received from this board in the past few weeks. If anyone can give some direction it would be apppreciated.

The worksheet details are as follows:

The worksheet is called "Invoice".

Column headings start in B12 through L12.
Data begins in Row 14 and input will be linited to Row 2000.

Row range selection for the user will read:
"Print Row Range 14 To 100"
The number 14, which canvary, is ing cell J6.
The number 100, which canvary, is ing cell L6.

I would like to be able to use selectabe range to select the
Print Area and to show the Print Preview for the user to verify.

Is this possible?

Thanks in advance.
 

Some videos you may like

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off

Barrie Davidson

MrExcel MVP
Joined
Feb 10, 2002
Messages
2,330
Something like?
Code:
ActiveSheet.PageSetup.PrintArea = "$B$" & Range("J6") & ":$L$" & Range("L6")
ActiveSheet.PrintPreview

Regards,
 

ARIZONA3433

Board Regular
Joined
Dec 8, 2005
Messages
56
Thanks, that worked for selectiong the row to print but I would need the column header and rows 1 through 11 to show on the page.

Possible?
 

Barrie Davidson

MrExcel MVP
Joined
Feb 10, 2002
Messages
2,330
ARIZONA3433 said:
Thanks, that worked for selectiong the row to print but I would need the column header and rows 1 through 11 to show on the page.

Possible?

Code:
With ActiveSheet.PageSetup
    .PrintArea = "$B$" & Range("J6") & ":$L$" & Range("L6")
    .PrintTitleRows = "$1:$11"
End With
ActiveSheet.PrintPreview
 

ARIZONA3433

Board Regular
Joined
Dec 8, 2005
Messages
56

ADVERTISEMENT

Thanks, it worked great. I only had to make one minor change.

Sub PrintArea()

With ActiveSheet.PageSetup
.PrintArea = "$B$" & Range("J6") & ":$L$" & Range("L6")
.PrintTitleRows = "$1:$12"
End With
ActiveSheet.PrintPreview
End Sub
 

Barrie Davidson

MrExcel MVP
Joined
Feb 10, 2002
Messages
2,330
ARIZONA3433 said:
Thanks, it worked great. I only had to make one minor change.

Sub PrintArea()

With ActiveSheet.PageSetup
.PrintArea = "$B$" & Range("J6") & ":$L$" & Range("L6")
.PrintTitleRows = "$1:$12"
End With
ActiveSheet.PrintPreview
End Sub

Hmmm, should have paid a little closer attention. Column header and rows 1 through 11. Haste makes waste. :cool:
 

ARIZONA3433

Board Regular
Joined
Dec 8, 2005
Messages
56
I should have explained that the minor change allows for the column headers in row 12 to be printed along with the selected rows.

Thanks again for all your help.
 

Watch MrExcel Video

Forum statistics

Threads
1,118,167
Messages
5,570,639
Members
412,334
Latest member
ExcelForLifeDontHate
Top