View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
skrimpy[_5_] skrimpy[_5_] is offline
external usenet poster
 
Posts: 1
Default Looping through text boxes


Thanks Tom. It works great. Is the way that I was doing thi
incorrect? I was under the impression that it was best to us
variables where ever possible.

Tom Ogilvy Wrote:
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

--
Regards,
Tom Ogilv


--
skrimp
-----------------------------------------------------------------------
skrimpy's Profile: http://www.excelforum.com/member.php...fo&userid=1463
View this thread: http://www.excelforum.com/showthread.php?threadid=26346