Hi guys. I've very new to VBR. I'm trying to understand how I can trigger a function from another worksheet. A basic example:
Sheet1:
Function ChangeBgColor()
Range("A1").Interior.ColorIndex = 37
End Function
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
ChangeBgColor
End Sub
The above code simply changes the color of cell A1 when a double-click happens on any cell in the sheet.
If I wanted to to trigger the function on Sheet1 from a double-click on Sheet2, I am trying:
Sheet2:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Dim ws As Worksheet
Set ws = Sheets("Sheet1")
ws.ChangeBgColor
End Sub
This results in a compile error "Method or data member not found."
Please understand that this is not a functional example; it's just something simple to convey what I need. I'm well aware that if this was an actual example, i could simply change the cell color on Sheet1 from Sheet2 directly. The point is that I would like to call the function on Sheet1 from Sheet2. Is that possible?
Thanks!
Bookmarks