Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Automatic print area
When i try i have an error on Cells (a1,Lastrow)
Why? Thanks -----Original Message----- If you don't set the print area, Excel should automatically print the whole page - an it should handle hidden rows automatically as well - so no code should be required if you remove the print area in insert=Names=define. but, if you only want to print column A Sub print() LastRow = Range("a65000").End(xlUp).Offset(1, 5) Cells(A1, LastRow).Select ActiveSheet.PageSetup.PrintArea = "$A$1:A" & LastRow" Selection.PrintOut Copies:=1, Collate:=True But it appears you might want to print 5 columns ActiveSheet.PageSetup.PrintArea = "$A$1:E" & LastRow" Regards, Tom Ogilvy "Peter" wrote in message ... Hi, i have an area to print. It always is not equal, does every time depend on the extraction of the data that youare filtered in the report, I have a base of the code here, as does it have to be correct? Thanks in advance.Pit Sub print() LastRow = Range("a65000").End(xlUp).Offset(1, 5).Select Cells(A1, LastRow).Select ActiveSheet.PageSetup.PrintArea = "$A$1:LastRow" Selection.PrintOut Copies:=1, Collate:=True End Sub . |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Automatic print area
Cells(a1,lastrow) would require a variable named A1 having a value that is a
legitimate row - suspect that is not what your intent was. I didn't pay any attention to that line, unfortunately. It is unnecesary, but perhaps you want to select the last cell in column A: Sub print() LastRow = Range("a65000").End(xlUp).Offset(1, 5) Cells(LastRow, "A").Select ActiveSheet.PageSetup.PrintArea = "$A$1:A" & LastRow Selection.PrintOut Copies:=1, Collate:=True Also, in cleaning up your code, looks like I left the stray double quote on the "$A$1:A" & LastRow part. I removed it as well. and ActiveSheet.PageSetup.PrintArea = "$A$1:E" & LastRow" should be ActiveSheet.PageSetup.PrintArea = "$A$1:E" & LastRow Sorry for the oversight. Regards, Tom Ogilvy "Peter" wrote in message ... When i try i have an error on Cells (a1,Lastrow) Why? Thanks -----Original Message----- If you don't set the print area, Excel should automatically print the whole page - an it should handle hidden rows automatically as well - so no code should be required if you remove the print area in insert=Names=define. but, if you only want to print column A Sub print() LastRow = Range("a65000").End(xlUp).Offset(1, 5) Cells(A1, LastRow).Select ActiveSheet.PageSetup.PrintArea = "$A$1:A" & LastRow" Selection.PrintOut Copies:=1, Collate:=True But it appears you might want to print 5 columns ActiveSheet.PageSetup.PrintArea = "$A$1:E" & LastRow" Regards, Tom Ogilvy "Peter" wrote in message ... Hi, i have an area to print. It always is not equal, does every time depend on the extraction of the data that youare filtered in the report, I have a base of the code here, as does it have to be correct? Thanks in advance.Pit Sub print() LastRow = Range("a65000").End(xlUp).Offset(1, 5).Select Cells(A1, LastRow).Select ActiveSheet.PageSetup.PrintArea = "$A$1:LastRow" Selection.PrintOut Copies:=1, Collate:=True End Sub . |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
set area in excel not giving me option to set print area? | Excel Discussion (Misc queries) | |||
File, print area, clear area, is not working | New Users to Excel | |||
print area across the freeze panes area | Excel Worksheet Functions | |||
Pivot Table macro to set print area and print details of drill down data | Excel Discussion (Misc queries) | |||
How do you turn off a print area for a page? (no print area) | Excel Discussion (Misc queries) |