K
KimberlyC
Hi
I posted a message yesterday regarding setting the print area of a
worksheet..
I've since decided to change up the worksheet a little....
So.. now my question is:
Is there a way to set the print area of all the worksheets in the
activeworkbook ...that begin with the name "cap i details" (as there can be
many sheets with the name cap i details ..for ex: cap i details (2), cap i
details (3)...etc...) to the last entry in COL A and the last entry in ROW 8
?
The code below (again) is what this group helped me out with .... when I
only had columns A-K to worry about printing..as this code sets the print
area to the columns A - K and the last entry in col A.
Now that I will have additional columns and will not always know how many
will be used... I want to set the print area to the last entry in ROW 8 and
the last entry in COL A.
This seems a bit easier to do than my previous post... but I still can seem
to figure it out..
Any help would be greatly appreicated..
I've been researching this all day...and still can't figure it out!!
****************
Public Sub PrintareaCAPIDetails()
Set sh1 = ActiveWorkbook.ActiveSheet
For Each Sh In ActiveWorkbook.Worksheets
If Left(LCase(Sh.Name), 13) = "cap i details" Then
Sh.Activate
ActiveWorkbook.ActiveSheet.PageSetup.PrintArea = "A1:K" & _
LastInCol(Sh.Range("A1"))
End If
Next
sh1.Activate
PrintForm.Show
End Sub
******************************************
Public Function LastInCol(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
LastInCol = WorkRange(i).Row
Exit Function
End If
Next i
End Function
I posted a message yesterday regarding setting the print area of a
worksheet..
I've since decided to change up the worksheet a little....
So.. now my question is:
Is there a way to set the print area of all the worksheets in the
activeworkbook ...that begin with the name "cap i details" (as there can be
many sheets with the name cap i details ..for ex: cap i details (2), cap i
details (3)...etc...) to the last entry in COL A and the last entry in ROW 8
?
The code below (again) is what this group helped me out with .... when I
only had columns A-K to worry about printing..as this code sets the print
area to the columns A - K and the last entry in col A.
Now that I will have additional columns and will not always know how many
will be used... I want to set the print area to the last entry in ROW 8 and
the last entry in COL A.
This seems a bit easier to do than my previous post... but I still can seem
to figure it out..
Any help would be greatly appreicated..
I've been researching this all day...and still can't figure it out!!
****************
Public Sub PrintareaCAPIDetails()
Set sh1 = ActiveWorkbook.ActiveSheet
For Each Sh In ActiveWorkbook.Worksheets
If Left(LCase(Sh.Name), 13) = "cap i details" Then
Sh.Activate
ActiveWorkbook.ActiveSheet.PageSetup.PrintArea = "A1:K" & _
LastInCol(Sh.Range("A1"))
End If
Next
sh1.Activate
PrintForm.Show
End Sub
******************************************
Public Function LastInCol(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
LastInCol = WorkRange(i).Row
Exit Function
End If
Next i
End Function