djburnheim
Technical User
I have a spreadsheet with a command button for each day of the month. I want the click event for each button to be the same. I also want to reference the cell above which ever command button was pushed. Hopefully you can tell from the code below what I'm trying to do (I know that it is wrong and doesn't work but I hope you can tell what I'm trying to get at)...any suggestions?
Private Sub Test()
Dim Ob As OLEObject
Dim FormLabel As String
For Each Ob In Sheets(1).OLEObjects
If TypeName(Ob.Object) = "CommandButton" Then
With Ob.Object
FormLabel = "Red Alerts for "
frmRedAlerts.Caption = FormLabel & Format(Sheets(1).Cells(1, 2), "d-MMM"
frmRedAlerts.Show
End With
End If
Next Ob
End Sub
Private Sub Test()
Dim Ob As OLEObject
Dim FormLabel As String
For Each Ob In Sheets(1).OLEObjects
If TypeName(Ob.Object) = "CommandButton" Then
With Ob.Object
FormLabel = "Red Alerts for "
frmRedAlerts.Caption = FormLabel & Format(Sheets(1).Cells(1, 2), "d-MMM"
frmRedAlerts.Show
End With
End If
Next Ob
End Sub