View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default Need a macro to loop evaluation of many textboxes in a UserForm.



"excelnut1954" wrote in message
oups.com...
Bob,
If you check back on this, thanks.
I appreciate the help.

I tried this out, and what it will do as you wrote it, it will locate
the PO# given in Textbox1 alright, but doesn't paste any info given,
except for Textbox41, which is the easy one because it doesn't deal
with any variables within this loop. I have a couple of questions :
######In the 1st section,
For i = 1 To 2 '13
does the '13 represent where I implied that there were 13 textboxes
that would have PO numbers? Does it mean I should change the code so
that it repeats this 13 times?


Yes it means exactly that. I reduced the loop for my testing and forgot to
revert back.

######In the line
CountPOtoValidate = Application.CountIf(Range("J:J"), PO1)
The PO1 part comes from the Change Event for TextBox1. I originally
used that to give that value a name. It works fine in my original
coding, BUT, as I said before, my code will only work for Textbox1.
Which is why I need help with the For-Next loop.
Is there something I can put under the line
If Me.Controls("TextBox" & i * 2 - 1).Text < "" Then
That will give the textbox being evaluated a variable name to plug into
this line. A name that would be used through each loop to stand for the
next Textbox.


Is this what you mean?

PO1 = Me.Controls("TextBox" & i * 2 - 1).Text

I have other questions about all this. But, maybe I can deal with
these 2 first. Sorry if this is confusing. I'm trying to explain this
the best I can. This For-Next will still take some time for me to
understand.


Just fire any more if you have them. I will watch the thread.