Write value to a textbox in Userform - VBA

Viewed 4341

I am trying to write a value dynamically in Textbox which is placed on a Userform. This is my code, and I am getting an error in the last line. It says object required.

Sub Userform1_Display()

TotalSelected = 0

With Sheets("Main").Ent_ListBox

    For i = 0 To .ListCount - 1
        If .Selected(i) = True Then
          Count = 1
          TotalSelected = TotalSelected + Count
        End If
    Next i

End With

'Useform'
Questionaire.Show

'TextBox placed in Userform'
N_Ent_TextBox.Value = TotalSelected


End Sub

Kindly share your thoughts

2 Answers
Related