2

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 2

3

It looks like your code isn't actually inside the userform's class module - so you need to fully qualify the object:

Questionaire.N_Ent_TextBox.Value = TotalSelected
Sign up to request clarification or add additional context in comments.

2 Comments

No worries, don't forget to accept the answer if it solved your problem.
Will Accept it. It says I have to wait for 6 minutes to accept it :)
-1

N_Ent_TextBox.Text = TotalSelected try to use this

1 Comment

No, It still says object required !

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.