For Each array - TextBoxes in a UserForm

E

excelnut1954

TextBoxe2 through TextBox21 might or might not be filled in by the
user. If any one is, then I want to go to a sub named EnterRecords.

I thought a For Each loop could work to test each TextBox for entry. I
know this is not correct syntax, but this is what I'm trying to do....

For Each (TextBox2 through Textbox21)
If TextBox*.Text = " " Then
EnterRecords
End If
Next

Am I close? Can it be this simple?
Thanks,
J.O.
 
E

excelnut1954

Thanks, Martin.
This worked fine. For future reference to anyone reading this, looking
for similar help, I had to change it slightly. Because I had the code
in a Standard Module, I had to change the 1st line to:
if UserForm3.controls("TextBox" & i) <> "" Then

When I ran it the way it was written below, it gave me an error, but
Help was pretty clear on what I needed to do.

Thanks again for your help, and to others who contributed, too.
J.O.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top