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

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
One way
Put ba_betPlaced in Module1
 
Upvote 0

Forum statistics

Threads
1,215,222
Messages
6,123,709
Members
449,118
Latest member
MichealRed

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