Replaced CLICK event for CALL event but now see Run time error

ipbr21054

Well-known Member
Joined
Nov 16, 2010
Messages
5,596
Office Version
  1. 2007
Platform
  1. 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



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
 

Attachments

  • EaseUS_2024_07_ 7_09_22_40.jpg
    EaseUS_2024_07_ 7_09_22_40.jpg
    70.9 KB · Views: 23

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Is the sub DISCOHYPERLINK a Public or a Private sub... If it is Private, hence the error.
 
Upvote 0
How do i find the answer as no option to see properties.
 
Upvote 0
Sorry, I did not see your attachment at the bottom of your post. My comment is incorrect as the image clearly shows it is a Public Sub. My bad- sorry for the confusion.
 
Upvote 0
Getting confused here.
I see the same as in screenshot

Sub DISCOHYPERLINK()
 
Upvote 0
Again, I apologize for the confusion. It is a Public Sub so my original reply is not applicable...
 
Upvote 0
Solution
I know you have typed it in twice in this post, but you may want to go back to your code and make sure all you spellings are correct on the Call (just a thought) and that the call is outside of the End with statements...
 
Upvote 0

Forum statistics

Threads
1,220,965
Messages
6,157,119
Members
451,398
Latest member
rjsteward

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