Problem adding a shortcut letter

Pauljj

Well-known Member
Joined
Mar 28, 2004
Messages
2,047
This macro works perfectly but for some reason I can now no longer add a shortcut key to it

I went to Alt+F8, selected the macro, went to options and added the small letter P (also tried D just in case) clicked ok but when I entered Ctrl+Shift+P nothing at all happened. When I go to Alt+F11 and run the code manually, it works perfectly

Public Sub Print_Page_of_ActiveCell()
Dim ActiveRow As Long, ActiveCol As Integer
Dim iHPBs As Integer, iVPBs As Integer
Dim iRow As Integer, iCol As Integer, iPage As Integer

ActiveRow = ActiveCell.Row
ActiveCol = ActiveCell.Column
ActiveSheet.UsedRange
If IsEmpty(ActiveCell.SpecialCells(xlCellTypeLastCell)) Then _
ActiveCell.SpecialCells(xlCellTypeLastCell).FormulaR1C1 = " "
If ActiveRow > ActiveCell.SpecialCells(xlCellTypeLastCell).Row Or _
ActiveCol > ActiveCell.SpecialCells(xlCellTypeLastCell).Column Then _
Exit Sub

With ActiveSheet
iHPBs = .HPageBreaks.Count
iVPBs = .VPageBreaks.Count
If iHPBs = 0 And iVPBs = 0 Then Goto PrintSheet
Horizontal:
For iRow = iHPBs To 1 Step -1
If .HPageBreaks(iRow).Location.Row <= ActiveRow Then Goto Vertical
Next iRow
Vertical:
For iCol = iVPBs To 1 Step -1
If .VPageBreaks(iCol).Location.Column <= ActiveCol Then Goto PrintSheet
Next iCol
PrintSheet:
iPage = (iRow + 1) + (iCol * (iHPBs + 1))
.PrintOut From:=iPage, To:=iPage
MsgBox "Printing page " & iPage
End With
If ActiveCell.SpecialCells(xlCellTypeLastCell).FormulaR1C1 = " " Then _
Selection.SpecialCells(xlCellTypeLastCell).ClearContents
End Sub
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
It wouldn't be Ctrl + Shift + p it would be Ctrl + p
 
Upvote 0

Forum statistics

Threads
1,224,599
Messages
6,179,827
Members
452,946
Latest member
JoseDavid

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top