fatboyzfishing
fatboyzfishing

Reputation: 151

Change userform textbox value with cell double-click event

I have been searching for a answer all morning and have not come up with a solution. I want to change the value of a textbox1 on userform1 after a double click event. I keep getting the method or data member not found error. How do I complete this from the double click event?

Public Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Not Intersect(Target, Worksheets("Offense").Range("A:A")) Is Nothing Then
    Cancel = True
    DataCollectionFormValid.Show
    Me.RowNumber.Value = ActiveCell.Row ' error here
End If
End Sub

Upvotes: 1

Views: 903

Answers (1)

Rory
Rory

Reputation: 34045

Me refers to the object running the code, which in this case is the worksheet, not the userform. You need:

Public Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Not Intersect(Target, Worksheets("Offense").Range("A:A")) Is Nothing Then
    Cancel = True
    With DataCollectionFormValid
      .RowNumber.Value = ActiveCell.Row
      .Show
    End With
End If
End Sub

Upvotes: 1

Related Questions