ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Looping through text boxes (https://www.excelbanter.com/excel-programming/311479-looping-through-text-boxes.html)

skrimpy[_5_]

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



All times are GMT +1. The time now is 11:20 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com