Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
Can anyone help me with a macro to search down column A from row 15 onwards (inclusive) until it finds the last cell containing any text (cell #), and then set the print area to cells A1:X#, where # is the last cell in column A containing any text? Any help with this would be much appreciated! Thanks in advance, Nick |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Nick,
Try: '============= Public Sub Tester() Dim SH As Worksheet Dim rng As Range Dim LRow As Long Set SH = ActiveSheet '<<==== CHANGE With SH LRow = SH.Cells(Rows.Count, "A").End(xlUp).Row Set rng = .Range("A15:A" & LRow) .PageSetup.PrintArea = rng.Address End With End Sub '<<============= --- Regards, Norman "Nick Smith" wrote in message ... Hi, Can anyone help me with a macro to search down column A from row 15 onwards (inclusive) until it finds the last cell containing any text (cell #), and then set the print area to cells A1:X#, where # is the last cell in column A containing any text? Any help with this would be much appreciated! Thanks in advance, Nick |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Nick,
Change: Set rng = .Range("A15:A" & LRow) to Set rng = .Range("A15:X" & LRow) where X is the last column to be printed. --- Regards, Norman |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Another thank you. Works a treat.
"Norman Jones" wrote: Hi Nick, Try: '============= Public Sub Tester() Dim SH As Worksheet Dim rng As Range Dim LRow As Long Set SH = ActiveSheet '<<==== CHANGE With SH LRow = SH.Cells(Rows.Count, "A").End(xlUp).Row Set rng = .Range("A15:A" & LRow) .PageSetup.PrintArea = rng.Address End With End Sub '<<============= --- Regards, Norman "Nick Smith" wrote in message ... Hi, Can anyone help me with a macro to search down column A from row 15 onwards (inclusive) until it finds the last cell containing any text (cell #), and then set the print area to cells A1:X#, where # is the last cell in column A containing any text? Any help with this would be much appreciated! Thanks in advance, Nick |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Print Area Setting | Excel Discussion (Misc queries) | |||
Setting The Print-Area ? | New Users to Excel | |||
Setting the print area | Excel Programming | |||
Setting The Print Area | Excel Programming | |||
setting a print area | Excel Programming |