Convert Sheet Events to Macro's

jc0r

Board Regular
Joined
Mar 16, 2009
Messages
124
Hi all, i have the below example of code that detects when BACK_COM is in cell T5 of Sheet1. When ba.placeBet is initiated, the program "Betting Assistant" will automatically call ba_betPlaced.

What i am looking to do is rather than have the initial ba.placeBet triggered on Workseet_Change, i would like to run it myself as a Macro. This i have done, however, when this now runs as a macro in a module, it will not trigger the ba_betPlaced routine on Sheet1. I have tried setting it to Public with no success.

Any ideas please?

Many thanks

Original Code:

Code:
Dim WithEvents ba As BettingAssistantCom.ComClass

Private Sub ba_betPlaced(ByVal ref As String, ByVal avgPriceMatched As Double, ByVal sizeMatched As Double)
    [T5] = ref
    [V5] = avgPriceMatched
    [W5] = sizeMatched
End Sub


Private Sub Worksheet_Change(ByVal Target As Range)
        If [Q5] = "BACK_COM" And [T5] = "" Then
            ba.placeBet 0, "B", [R5], [S5], False, ""
        End If
End Sub

Where i am at the moment:

Sheet1:
Code:
Dim WithEvents ba As BettingAssistantCom.ComClass

Public Sub ba_betPlaced(ByVal ref As String, ByVal avgPriceMatched As Double, ByVal sizeMatched As Double)
    [T5] = ref
    [V5] = avgPriceMatched
    [W5] = sizeMatched
End Sub

Module1:

Code:
Dim ba As New BettingAssistantCom.ComClassPublic 
Sub Test()
    If ba Is Nothing Then
        Set ba = New BettingAssistantCom.ComClass
    End If


            ba.placeBet 0, "B", "100", "2", False, ""


End Sub
 
Last edited:

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple

Forum statistics

Threads
1,223,702
Messages
6,173,957
Members
452,539
Latest member
delvey

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