D
Don Lowe
I have many people using the file. Each person only needs a page worth of
information. I need a Macro to print curent page only.
I am hoping to have a macro that looks at what pape I am on and will print
the specific page. This way I do not need to make 97 buttons for printing.
One button printing where ever you are (most of my users would not now where
they are and I am trying to make this really really easy for them).
The following code is what one person gave me. I just can't get it to work.
Please help!!!
Function PageInfo(currCell As Range)
Dim iPages As Integer
Dim iCol As Integer
Dim iCols As Integer
Dim lRows As Long
Dim lRow As Long
Dim x As Long
Dim y As Long
Dim hBreaks As Long
Dim vBreaks As Long
Application.ScreenUpdating = False
ActiveWindow.View = xlPageBreakPreview
hBreaks = Worksheets(1).HPageBreaks.Count
vBreaks = Worksheets(1).VPageBreaks.Count
iPages = (hBreaks + 1) * (vBreaks + 1)
With ActiveSheet
y = currCell.Column
iCols = .VPageBreaks.Count
x = 0
Do
x = x + 1
Loop Until x = iCols _
Or y < .VPageBreaks(x).Location.Column
iCol = x
If y >= .VPageBreaks(x).Location.Column Then
iCol = iCol + 1
End If
y = ActiveCell.Row
lRows = .HPageBreaks.Count
x = 0
Do
x = x + 1
Loop Until x = lRows _
Or y < .HPageBreaks(x).Location.Row
lRow = x
If y >= .HPageBreaks(x).Location.Row Then
lRow = lRow + 1
End If
If .PageSetup.Order = xlDownThenOver Then
PageInfo = (iCol - 1) * (lRows + 1) + lRow
Else
PageInfo = (lRow - 1) * (iCols + 1) + iCol
End If
End With
Application.ScreenUpdating = True
ActiveWindow.View = xlNormalView
End Function
Sub printpage()
Dim p As Long
p = PageInfo(ActiveCell)
ActiveSheet.PrintOut From:=p, To:=p
End Sub
information. I need a Macro to print curent page only.
I am hoping to have a macro that looks at what pape I am on and will print
the specific page. This way I do not need to make 97 buttons for printing.
One button printing where ever you are (most of my users would not now where
they are and I am trying to make this really really easy for them).
The following code is what one person gave me. I just can't get it to work.
Please help!!!
Function PageInfo(currCell As Range)
Dim iPages As Integer
Dim iCol As Integer
Dim iCols As Integer
Dim lRows As Long
Dim lRow As Long
Dim x As Long
Dim y As Long
Dim hBreaks As Long
Dim vBreaks As Long
Application.ScreenUpdating = False
ActiveWindow.View = xlPageBreakPreview
hBreaks = Worksheets(1).HPageBreaks.Count
vBreaks = Worksheets(1).VPageBreaks.Count
iPages = (hBreaks + 1) * (vBreaks + 1)
With ActiveSheet
y = currCell.Column
iCols = .VPageBreaks.Count
x = 0
Do
x = x + 1
Loop Until x = iCols _
Or y < .VPageBreaks(x).Location.Column
iCol = x
If y >= .VPageBreaks(x).Location.Column Then
iCol = iCol + 1
End If
y = ActiveCell.Row
lRows = .HPageBreaks.Count
x = 0
Do
x = x + 1
Loop Until x = lRows _
Or y < .HPageBreaks(x).Location.Row
lRow = x
If y >= .HPageBreaks(x).Location.Row Then
lRow = lRow + 1
End If
If .PageSetup.Order = xlDownThenOver Then
PageInfo = (iCol - 1) * (lRows + 1) + lRow
Else
PageInfo = (lRow - 1) * (iCols + 1) + iCol
End If
End With
Application.ScreenUpdating = True
ActiveWindow.View = xlNormalView
End Function
Sub printpage()
Dim p As Long
p = PageInfo(ActiveCell)
ActiveSheet.PrintOut From:=p, To:=p
End Sub