Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 175
Default For Each array - TextBoxes in a UserForm

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.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 175
Default For Each array - TextBoxes in a UserForm

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.

Martin Fishlock wrote:
Hi:

Try this, you were quite close:

dim i as integer
For i=2 to 21
if me.controls("TextBox" & i) < "" Then
EnterRecords
End If
Next i

--
Hope this helps
Martin Fishlock
Please do not forget to rate this reply.


"excelnut1954" wrote:

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.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
UserForm TextBoxes Rob Excel Discussion (Misc queries) 2 August 6th 05 03:07 AM
selection all textboxes in userform at once Marthijn Beusekom via OfficeKB.com Excel Programming 2 February 19th 05 01:08 AM
userform & textboxes beginner Excel Programming 3 July 27th 04 10:56 AM
userform textboxes again Jo[_6_] Excel Programming 4 October 21st 03 07:25 PM
userform textboxes Jo[_6_] Excel Programming 4 October 21st 03 07:15 PM


All times are GMT +1. The time now is 08:09 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"