PC Review


Reply
Thread Tools Rate Thread

How can I print from cell A1 to the last row ?

 
 
Ro477
Guest
Posts: n/a
 
      9th Jan 2009
Thanks to all for their help so far. I can find the last row okay, but how
can I now print from cell A1 through to the last row +2, column 24 ?

Dim IngLastRow As Long
With Sheets("Report(metArb)")
lngLastRow = .Cells(Rows.Count, "B").End(xlUp).Row + 2
End With

.... that finds the last row, but to print from A1 to the lastrow+2 (which is
IngLastRow) is it

ActiveSheet.PageSetup.PrintArea = "$A$1:" & "IngLastRow+2,24"

thanks again ... Roger



 
Reply With Quote
 
 
 
 
Rick Rothstein
Guest
Posts: n/a
 
      9th Jan 2009
There are a couple of problems with your statement. First, your IngLastRow
variable name is place inside quote marks, so VB will treat is as pure text
(anything inside quote marks is text with no meaning other than as a
collection of letters). To have VB evaluate the variable in order to
retrieve its contents, you must concatenate the variable to the fixed text.
Second, you start your range address with $A$1: and then try to finish it
off with a row-comma-column... you can't mix notations like that as VB will
have no idea what you are doing. This should be the line of code you are
looking for...

ActiveSheet.PageSetup.PrintArea = "$A$1:X" & (IngLastRow + 2)

--
Rick (MVP - Excel)


"Ro477" <help-(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Thanks to all for their help so far. I can find the last row okay, but how
> can I now print from cell A1 through to the last row +2, column 24 ?
>
> Dim IngLastRow As Long
> With Sheets("Report(metArb)")
> lngLastRow = .Cells(Rows.Count, "B").End(xlUp).Row + 2
> End With
>
> ... that finds the last row, but to print from A1 to the lastrow+2 (which
> is IngLastRow) is it
>
> ActiveSheet.PageSetup.PrintArea = "$A$1:" & "IngLastRow+2,24"
>
> thanks again ... Roger
>
>
>


 
Reply With Quote
 
Bernard Liengme
Guest
Posts: n/a
 
      9th Jan 2009
This works

Sub tryme()
With Sheets("sheet1")
lngLastRow = Cells(Rows.Count, "B").End(xlUp).Row + 2
myarea = "$A$1:$B" & lngLastRow
.PageSetup.PrintArea = myarea
End With
End Sub

Not sure what your 24 is about. Is it column a reference to column X?
If so use: myarea = "$A$1:$X" & lngLastRow
--
Bernard V Liengme
Microsoft Excel MVP
http://people.stfx.ca/bliengme
remove caps from email

"Ro477" <help-(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Thanks to all for their help so far. I can find the last row okay, but how
> can I now print from cell A1 through to the last row +2, column 24 ?
>
> Dim IngLastRow As Long
> With Sheets("Report(metArb)")
> lngLastRow = .Cells(Rows.Count, "B").End(xlUp).Row + 2
> End With
>
> ... that finds the last row, but to print from A1 to the lastrow+2 (which
> is IngLastRow) is it
>
> ActiveSheet.PageSetup.PrintArea = "$A$1:" & "IngLastRow+2,24"
>
> thanks again ... Roger
>
>
>



 
Reply With Quote
 
Ro477
Guest
Posts: n/a
 
      10th Jan 2009
Great, thanks, and especially for the explanation. I now understand it !
.... Ro



"Rick Rothstein" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> There are a couple of problems with your statement. First, your IngLastRow
> variable name is place inside quote marks, so VB will treat is as pure
> text (anything inside quote marks is text with no meaning other than as a
> collection of letters). To have VB evaluate the variable in order to
> retrieve its contents, you must concatenate the variable to the fixed
> text. Second, you start your range address with $A$1: and then try to
> finish it off with a row-comma-column... you can't mix notations like that
> as VB will have no idea what you are doing. This should be the line of
> code you are looking for...
>
> ActiveSheet.PageSetup.PrintArea = "$A$1:X" & (IngLastRow + 2)
>
> --
> Rick (MVP - Excel)
>
>
> "Ro477" <help-(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
>> Thanks to all for their help so far. I can find the last row okay, but
>> how
>> can I now print from cell A1 through to the last row +2, column 24 ?
>>
>> Dim IngLastRow As Long
>> With Sheets("Report(metArb)")
>> lngLastRow = .Cells(Rows.Count, "B").End(xlUp).Row + 2
>> End With
>>
>> ... that finds the last row, but to print from A1 to the lastrow+2 (which
>> is IngLastRow) is it
>>
>> ActiveSheet.PageSetup.PrintArea = "$A$1:" & "IngLastRow+2,24"
>>
>> thanks again ... Roger
>>
>>
>>

>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to hide rows with a certain cell empty then set print area and print tahrah Microsoft Excel Programming 12 9th Jan 2007 03:47 AM
cell borders that I create dont show on print preview or print =?Utf-8?B?c2NvdHQzNDM1?= Microsoft Excel Misc 2 6th Apr 2006 02:37 AM
Active cell counting in particular print page (one sheet having different print area) ananthmca2004 Microsoft Excel Worksheet Functions 1 24th Nov 2005 11:29 AM
Excel cell looks good in print preview but doesn't print??? =?Utf-8?B?SmFjayBHYXRocmlnaHQ=?= Microsoft Excel Misc 1 13th Sep 2005 12:38 PM
Cell data missing on print & print preview Gareth Microsoft Excel Crashes 1 7th Nov 2003 10:04 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:31 AM.