I'm trying to have the event handler from a userform select a cell on a worksheet. The form's showmodal property is false. I tried using activecell and was getting errors...I speculted that maybe Excel didn't consider the worksheet active because the form was up. So then I tried storing an address and then going from there.
So here's the test event handler:
Where am I going wrong?
So here's the test event handler:
Code:
Private Sub btnLeft_Click()
Dim selectedCell As Range
Dim selectedAddress As String
ThisWorkbook.Worksheets("Board").Activate
selectedAddress = ThisWorkbook.Worksheets("Board").Range("AG1").Value 'this cell has "D5" in it
selectedCell = ThisWorkbook.Worksheets("Board").Range(selectedAddress) 'this line throws an error
'object variabe or with block variable not set
MsgBox selectedCell.Address
End Sub
Where am I going wrong?
Last edited: