ExcelBanter

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

skrimpy[_3_]

Looping through text boxes
 

I am in the process of equating values between an interface containing
many text boxes to cells that do a bunch of number crunching(ie 26
cells to 26 text boxes). I started by using 26 variables corresponding
to the data that was going back and forth through the text boxes and
their corresponding cells. I assume this is a very crude and most
likely incorrect method. Especially since it didn't work. Therefore,
I have written the below loop. Is there a way to name the text box, in
this case "t1" so that I can increment to the next set in the series
"t3" to apply the same code to the next text box and corresponding cell
in the sequence? Of course I realize that my nomenclature is not quite
"correct" and that I would have to also incremement variables a and b.
Thanks in advance to anyone that might help.
Private Sub cmdCalculate_Click()
Dim Counter As Integer
Dim a As Byte
Dim b As Byte
Dim c As String
Dim d As String
Worksheets("2 Parents").Activate
Counter = 0
a = 9
b = 3
c = Cells(b, a)
Do
If c = "n/a" Then
t1 = ActiveSheet.Cells(b, a - 1)
Else: t1 = ActiveSheet.Cells(b, a - 1) & "," & ActiveSheet.Cells(b,
a)
End If
Counter = Counter + 1
b = b + 1
Loop Until Counter = 1
End Sub


--
skrimpy
------------------------------------------------------------------------
skrimpy's Profile: http://www.excelforum.com/member.php...o&userid=14634
View this thread: http://www.excelforum.com/showthread...hreadid=263461


Tom Ogilvy

Looping through text boxes
 
Assume interface means Userform.

Private Sub cmdCalculate_Click()
Dim Counter As Integer
Dim a As Byte
Dim b As Byte
Dim c As String
Dim d As String
Worksheets("2 Parents").Activate
for j = 1 to 2*26 step 2
Counter = 0
a = 9
b = 3
c = Cells(b, a)
Do
If c = "n/a" Then
Userform1.Controls("t" & j).Value = _
ActiveSheet.Cells(b, a - 1)
Else
Userform1.Controls("t" & j).Value = _
ActiveSheet.Cells(b, a - 1) & "," & ActiveSheet.Cells(b,a)
End If
Counter = Counter + 1
b = b + 1
Loop Until Counter = 1
End Sub

might give you some ideas. I don't know what the interaction/relationship is
between b and a and each textbox, so you will have to figure that out.

--
Regards,
Tom Ogilvy

"skrimpy" wrote in message
...

I am in the process of equating values between an interface containing
many text boxes to cells that do a bunch of number crunching(ie 26
cells to 26 text boxes). I started by using 26 variables corresponding
to the data that was going back and forth through the text boxes and
their corresponding cells. I assume this is a very crude and most
likely incorrect method. Especially since it didn't work. Therefore,
I have written the below loop. Is there a way to name the text box, in
this case "t1" so that I can increment to the next set in the series
"t3" to apply the same code to the next text box and corresponding cell
in the sequence? Of course I realize that my nomenclature is not quite
"correct" and that I would have to also incremement variables a and b.
Thanks in advance to anyone that might help.
Private Sub cmdCalculate_Click()
Dim Counter As Integer
Dim a As Byte
Dim b As Byte
Dim c As String
Dim d As String
Worksheets("2 Parents").Activate
Counter = 0
a = 9
b = 3
c = Cells(b, a)
Do
If c = "n/a" Then
t1 = ActiveSheet.Cells(b, a - 1)
Else: t1 = ActiveSheet.Cells(b, a - 1) & "," & ActiveSheet.Cells(b,
a)
End If
Counter = Counter + 1
b = b + 1
Loop Until Counter = 1
End Sub


--
skrimpy
------------------------------------------------------------------------
skrimpy's Profile:

http://www.excelforum.com/member.php...o&userid=14634
View this thread: http://www.excelforum.com/showthread...hreadid=263461





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

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