ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Macro to print a cell range (https://www.excelbanter.com/excel-discussion-misc-queries/211419-macro-print-cell-range.html)

Tamsyn

Macro to print a cell range
 
I need to create a Macro to select a print area and then print. This range
will change as more data is added.


Jim Thomlinson

Macro to print a cell range
 
We need a lot more info to create a macro. Perhaps there is an easier way.
The print area for a worksheet is stored as a locally defined named range
called Print_Area. You can change the print area by changing the range
specified in this named range. Here is where it gets interesting. You can
change the print area dynamically by making the named range Dynamic. There is
an excellent explanation of dynamic named ranges on Chip Pearson's website
but the site is down at the moment... google for it later and you should be
able to find how it works...

So if you change Print_Area to something like

=Offset(A1, 0,0, counta(A:A), counta(1:1))
then the print range will adjust as more data is added...
--
HTH...

Jim Thomlinson


"Tamsyn" wrote:

I need to create a Macro to select a print area and then print. This range
will change as more data is added.


Dave Peterson

Macro to print a cell range
 
This will print A1:X(lastusedrow of column A):

Option Explicit
Sub testme()
Dim LastRow As Long
With ActiveSheet
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
.Range("a1:x" & LastRow).PrintOut preview:=True
End With
End Sub

Tamsyn wrote:

I need to create a Macro to select a print area and then print. This range
will change as more data is added.


--

Dave Peterson


All times are GMT +1. The time now is 02:06 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com