Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 271
Default Print Area to last cell with data

Help,

we are constantly adding new data and trying to write a macro (which I am
new to) that will set the print area automatically to the last row with data
in it. Can someone please help me.... I have no idea what i am doing and
the people i am writing this for have less knowledge.

Any help would be appreciated!
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,123
Default Print Area to last cell with data

Hi Susan

Maybe easier ?

Clear the print area and it will print all the data on the worksheet


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Susan" wrote in message ...
Help,

we are constantly adding new data and trying to write a macro (which I am
new to) that will set the print area automatically to the last row with data
in it. Can someone please help me.... I have no idea what i am doing and
the people i am writing this for have less knowledge.

Any help would be appreciated!

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 271
Default Print Area to last cell with data

Thank you but that wont work because there are hidden formulas in the blank
rows underneath the last entry. i need to be able to print to the last row
with data in it, which happens to be XXX in A??

i just want the rows that actually have all the completed data not the rows
with formulas in it that have not been used yet

"Ron de Bruin" wrote:

Hi Susan

Maybe easier ?

Clear the print area and it will print all the data on the worksheet


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Susan" wrote in message ...
Help,

we are constantly adding new data and trying to write a macro (which I am
new to) that will set the print area automatically to the last row with data
in it. Can someone please help me.... I have no idea what i am doing and
the people i am writing this for have less knowledge.

Any help would be appreciated!


  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,123
Default Print Area to last cell with data

I understand

You can do it with code
This example will search for "XXX" in "Sheet1"
And will print A1:D & row of "XXX"

For testing I add
preview:=True

Delete this if you want to print


Sub PrintFromA1TillXXX()
Dim FindString As String
Dim Rng As Range

FindString = "XXX"

With Sheets("Sheet1").Range("A:A")
Set Rng = .Find(What:=FindString, _
After:=.Cells(1), _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious, _
MatchCase:=False)
If Not Rng Is Nothing Then
.Range("A1:D" & Rng.Row).PrintOut preview:=True
Else
MsgBox "Nothing found"
End If
End With
End Sub


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Susan" wrote in message ...
Thank you but that wont work because there are hidden formulas in the blank
rows underneath the last entry. i need to be able to print to the last row
with data in it, which happens to be XXX in A??

i just want the rows that actually have all the completed data not the rows
with formulas in it that have not been used yet

"Ron de Bruin" wrote:

Hi Susan

Maybe easier ?

Clear the print area and it will print all the data on the worksheet


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Susan" wrote in message ...
Help,

we are constantly adding new data and trying to write a macro (which I am
new to) that will set the print area automatically to the last row with data
in it. Can someone please help me.... I have no idea what i am doing and
the people i am writing this for have less knowledge.

Any help would be appreciated!


  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default Print Area to last cell with data

Susan,

Your question is short on detail so here's some options

lastrow = Cells.SpecialCells(xlLastCell).Row
This selects the last used row in the worksheet

lastrow = Cells(Cells.Rows.Count, "G").End(xlUp).Row
This select the last used cell in Column G

This small macro sets the print area but you must choose which 'lastrow' you
want and which column.

Sub stance()
lastrow = Cells.SpecialCells(xlLastCell).Row
lastrow = Cells(Cells.Rows.Count, "G").End(xlUp).Row
ActiveSheet.PageSetup.PrintArea = "$A$1:$G$" & lastrow
End Sub

Mike

"Susan" wrote:

Help,

we are constantly adding new data and trying to write a macro (which I am
new to) that will set the print area automatically to the last row with data
in it. Can someone please help me.... I have no idea what i am doing and
the people i am writing this for have less knowledge.

Any help would be appreciated!



  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 271
Default Print Area to last cell with data

Mike,

Thank you, that worked perfectly!!!

Susan

"Mike H" wrote:

Susan,

Your question is short on detail so here's some options

lastrow = Cells.SpecialCells(xlLastCell).Row
This selects the last used row in the worksheet

lastrow = Cells(Cells.Rows.Count, "G").End(xlUp).Row
This select the last used cell in Column G

This small macro sets the print area but you must choose which 'lastrow' you
want and which column.

Sub stance()
lastrow = Cells.SpecialCells(xlLastCell).Row
lastrow = Cells(Cells.Rows.Count, "G").End(xlUp).Row
ActiveSheet.PageSetup.PrintArea = "$A$1:$G$" & lastrow
End Sub

Mike

"Susan" wrote:

Help,

we are constantly adding new data and trying to write a macro (which I am
new to) that will set the print area automatically to the last row with data
in it. Can someone please help me.... I have no idea what i am doing and
the people i am writing this for have less knowledge.

Any help would be appreciated!

  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default Print Area to last cell with data

Glad I could help. remember the next time you post give as much detail as
possible.

Mike

"Susan" wrote:

Mike,

Thank you, that worked perfectly!!!

Susan

"Mike H" wrote:

Susan,

Your question is short on detail so here's some options

lastrow = Cells.SpecialCells(xlLastCell).Row
This selects the last used row in the worksheet

lastrow = Cells(Cells.Rows.Count, "G").End(xlUp).Row
This select the last used cell in Column G

This small macro sets the print area but you must choose which 'lastrow' you
want and which column.

Sub stance()
lastrow = Cells.SpecialCells(xlLastCell).Row
lastrow = Cells(Cells.Rows.Count, "G").End(xlUp).Row
ActiveSheet.PageSetup.PrintArea = "$A$1:$G$" & lastrow
End Sub

Mike

"Susan" wrote:

Help,

we are constantly adding new data and trying to write a macro (which I am
new to) that will set the print area automatically to the last row with data
in it. Can someone please help me.... I have no idea what i am doing and
the people i am writing this for have less knowledge.

Any help would be appreciated!

  #8   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2
Default Print Area to last cell with data

On Jul 8, 4:01 pm, Susan wrote:
Help,

we are constantly adding new data and trying to write a macro (which I am
new to) that will set the print area automatically to the last row with data
in it. Can someone please help me.... I have no idea what i am doing and
the people i am writing this for have less knowledge.

Any help would be appreciated!


try the following macro strip, Of course you will have to determine
where the end of the data is located (i call it lastpos)

ActiveSheet.PageSetup.PrintArea = Range(Cells(1, 1), Cells(lastpos,
15)).Address
printsetup

Application.ScreenUpdating = True

Function printsetup()

With ActiveSheet.PageSetup
.LeftHeader = ""
.CenterHeader = ""
.RightHeader = ""
.LeftFooter = ""
.CenterFooter = "&D"
.RightFooter = ""
.LeftMargin = Application.InchesToPoints(0.5)
.RightMargin = Application.InchesToPoints(0.5)
.TopMargin = Application.InchesToPoints(0.5)
.BottomMargin = Application.InchesToPoints(0.5)
.HeaderMargin = Application.InchesToPoints(0.5)
.FooterMargin = Application.InchesToPoints(0.5)
.PrintHeadings = False
.PrintGridlines = True
.PrintComments = xlPrintNoComments
.PrintQuality = 300
.CenterHorizontally = True
.CenterVertically = False
.Orientation = xlLandscape
.Draft = False
.PaperSize = xlPaperLetter
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = 1
.PrintErrors = xlPrintErrorsDisplayed
End With
End Function
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Print area giving me 1 page per cell Coop Excel Discussion (Misc queries) 4 September 19th 07 05:36 AM
Sorting data to a 'print' area ?? Ian Excel Discussion (Misc queries) 0 March 16th 06 08:10 PM
Pivot Table macro to set print area and print details of drill down data Steve Haskins Excel Discussion (Misc queries) 2 December 28th 05 04:59 PM
Active cell counting in particular print page (one sheet having different print area) ananthmca2004 Excel Worksheet Functions 1 November 24th 05 11:29 AM
How do you turn off a print area for a page? (no print area) Grunen Excel Discussion (Misc queries) 4 October 8th 05 07:46 PM


All times are GMT +1. The time now is 04:48 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"