Looping through text boxes

  • Thread starter Thread starter skrimpy
  • Start date Start date
S

skrimpy

Thanks. If you were wondering, I was trying to use the a and b a
index numbers to reference a specific cell. Just because you wer
curious, I have 13 pairs of cells and 13 text boxes. Each text bo
corresponds with a pair of cells. Each of the pairs of cells will hav
three possible configurations. 1: Both are "n/a" 2: The first is
number and the second is "n/a", or 3: Both are numbers.
Here are three examples of what I want it to do.
Cells H3, and I3 contain "n/a", when I click "Calculate" text box t
will get "n/a"
Cell H4 contains a 15, and Cell I4 contains "n/a", t2 will get "15"
Cell H5 contains a 15, and Cell I5 contains a 15, t3 will get "15,15"

My problem with it was that I know how to increment the cell inde
numbers to reference the next set of cells, but I don't know how t
name the text box so that I can increment it corresponding to th
incremented cell pair(if any of that makes sense. Thanks for the help
Ill try it out and see if I can figure something out
 
Assume the first cell is in row 3

Private sub CommandButton1_click()
for i = 3 to 15
if cells(i,8).Value = "n/a" and cells(i,9).Value = "n/a" then
Userform1.Controls("t" & i - 2).Value = "n/a"
elseif cells(i,8).Value <> "n/a" and cells(i,9).Value <> "n/a" then
Userform1.Controls("t" & i - 2).Value = cells(i,8).Value & ", " & _
cells(i,9).Value
elseif cells(i,8).Value <> "n/a" then
Userform1.controls("t" & i - 2).Value = cells(i,8).Value
end if
Next i
End sub

name the textboxes t1 to t13
 

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

Back
Top