LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 124
Default Help with setting Print area to more than one worksheet with VBA

Hi

I am running this code below (with help from this newsgroup) to set the
print area of the Active Worksheet to the last entry in col. b.
It works great...
However.. I now need to set the print area based on the same info (col b
"last entry" and A1:Q) for each worksheet that "starts" with the name
"Payroll..."
in the ActiveWorkbook.
I'm not sure how to do this..or if it can be done..
Any help would be greatly appreicated!!

Private Sub CommandButton1_Click()

ThisWorkbook.ActiveSheet.PageSetup.PrintArea = "A1:Q" &
LastInColumn(Range("b1"))

''get rid of this after testing
MsgBox "Print area set to " &
ThisWorkbook.ActiveSheet.PageSetup.PrintArea
End Sub

Function LastInColumn(rngInput As Range)
''Courtesy of http://www.j-walk.com, though a tad changed
Dim WorkRange As Range
Dim i As Integer, CellCount As Integer
Application.Volatile
Set WorkRange = rngInput.Columns(1).EntireColumn
Set WorkRange = Intersect(WorkRange.Parent.UsedRange, WorkRange)
CellCount = WorkRange.Count
For i = CellCount To 1 Step -1
If Not IsEmpty(WorkRange(i)) Then
LastInColumn = WorkRange(i).Row
Exit Function
End If
Next i
End Function


Thanks in advance!
Kimberly


 
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 Setting RozBuds Excel Discussion (Misc queries) 3 February 19th 10 09:41 PM
Setting The Print-Area ? Robert11[_3_] New Users to Excel 2 May 31st 09 03:24 PM
Setting print area with vba KimberlyC Excel Programming 3 December 18th 04 12:46 AM
SETTING PRINT AREA IN VBA Frankie[_2_] Excel Programming 6 June 24th 04 03:11 PM
Setting print area Don Guillett[_4_] Excel Programming 0 September 4th 03 02:14 PM


All times are GMT +1. The time now is 02:02 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"