ipbr21054
Well-known Member
- Joined
- Nov 16, 2010
- Messages
- 5,832
- Office Version
- 2007
- Platform
- Windows
I have the code below in use & works fine.
On my worksheet i have a Click Event but if i add it to my currently used code shown below it will make it much longer so i wanted to add the procedure where you would put Call instead.
So i put the code in a Module,see screenshot please
In the code in use i put it after the following like so.
Application.ScreenUpdating = True
Call DISCOHYPERLINK
I now get the message Sub or function Not Defined
On my worksheet i have a Click Event but if i add it to my currently used code shown below it will make it much longer so i wanted to add the procedure where you would put Call instead.
So i put the code in a Module,see screenshot please
In the code in use i put it after the following like so.
Application.ScreenUpdating = True
Call DISCOHYPERLINK
I now get the message Sub or function Not Defined
VBA Code:
Private Sub PurchasedKey_Click()
Dim sPath As String
Dim strFileName As String
Dim sh As Worksheet
With ActiveSheet
If .Range("Q1") = "" Then
MsgBox "NO CODE SHOWN TO GENERATE PDF", vbCritical, "NO CODE ON SHEET TO CREATE PDF"
Exit Sub
End If
If .Range("N1") = "M" Then
strFileName = "C:\Users\Ian\Desktop\REMOTES ETC\DISCO II CODE\DISCO II PDF\" & .Range("B3").Value & " " & Format(.Range("E3").Value, "dd-mm-yyyy") & " " & .Range("Q1").Value & " (SLS).pdf"
.Range("A1:K23").ExportAsFixedFormat Type:=xlTypePDF, Filename:=strFileName, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False
Else
strFileName = "C:\Users\Ian\Desktop\REMOTES ETC\DISCO II CODE\DISCO II PDF\" & .Range("B3").Value & ".pdf"
.Range("A1:K23").ExportAsFixedFormat Type:=xlTypePDF, Filename:=strFileName, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False
End If
With ActiveSheet
' ActiveWindow.SelectedSheets.PrintOut copies:=1
Unload PrinterForm
.Range("B3").Select
Application.ScreenUpdating = False
Dim c As Range
Dim ans As String
Dim Lastrow As Long
ans = ActiveCell.Value
Workbooks.Open ("C:\Users\Ian\Desktop\REMOTES ETC\DR\DR.xlsm")
Lastrow = Sheets("POSTAGE").Cells(Rows.Count, "B").End(xlUp).Row
For Each c In Sheets("POSTAGE").Range("B1:B" & Lastrow)
If c.Value = ans Then Application.Goto Reference:=Sheets("POSTAGE").Range(c.Address): Exit Sub
Next
Application.ScreenUpdating = True
End With
End With
End Sub