ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Loop help please! (https://www.excelbanter.com/excel-programming/354527-loop-help-please.html)

Rick_Stanich[_9_]

Loop help please!
 

I just dont quite grasp Loops yet. :sigh:
Mainly because I rarely need them.
Any how, I'm stuck so to speak, I have 60 TextBox's to iterate thru an
check a condition, how do I complete this?

For code, all i have is the first textbox.

"If Worksheets("sheet2").Range("a10").Interior.ColorIn dex = 3 Then
TextBox14.Visible = False
End If

--
Rick_Stanic

I am m
-----------------------------------------------------------------------
Rick_Stanich's Profile: http://www.excelforum.com/member.php...fo&userid=2895
View this thread: http://www.excelforum.com/showthread.php?threadid=51705


Bob Phillips[_6_]

Loop help please!
 

Dim i As Long
With Worksheets("sheet2")
For i = 1 To 50
.OLEObjects("TextBox" & i).Visible = _
.Range("A" & 10 + 1).Interior.ColorIndex = 3
Next i
End With

This compares Textbix1 with A11, 2 with A12, etc.

--

HTH

Bob Phillips

(remove nothere from the email address if mailing direct)

"Rick_Stanich"
wrote in message
news:Rick_Stanich.23wtta_1141080601.9758@excelforu m-nospam.com...

I just dont quite grasp Loops yet. :sigh:
Mainly because I rarely need them.
Any how, I'm stuck so to speak, I have 60 TextBox's to iterate thru and
check a condition, how do I complete this?

For code, all i have is the first textbox.

"If Worksheets("sheet2").Range("a10").Interior.ColorIn dex = 3 Then
TextBox14.Visible = False
End If"


--
Rick_Stanich

I am me
------------------------------------------------------------------------
Rick_Stanich's Profile:

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




Rick_Stanich[_10_]

Loop help please!
 

Now I see how the loop is created!
Unfortunately I get an error at the ".OLEObjects" line.

"Run-time error 1004"
"Unable to get OLEObjects property of the worksheet class"

I think "OLEObjects" pertains to worksheets and not TextBox's.
Maybe I did not mention I am working from a Form. (maybe ;) )


--
Rick_Stanich

I am me
------------------------------------------------------------------------
Rick_Stanich's Profile: http://www.excelforum.com/member.php...o&userid=28957
View this thread: http://www.excelforum.com/showthread...hreadid=517055


Rick_Stanich[_11_]

Loop help please!
 

This code runs thru but i am not getting the desired affect, Visible
false for the condition.

Dim obj As OLEObject
Dim i as Long

For Each obj In Worksheets("sheet2").OLEObjects
If TypeOf obj.Object Is MSForms.TextBox Then
With Worksheets("sheet2")
For i = 1 To 50
.OLEObjects("TextBox" & i).Visible = _
.Range("A" & 10 + 1).Interior.ColorIndex = 3
Next i
End With
End If
Next

Any help is appreciated

--
Rick_Stanic

I am m
-----------------------------------------------------------------------
Rick_Stanich's Profile: http://www.excelforum.com/member.php...fo&userid=2895
View this thread: http://www.excelforum.com/showthread.php?threadid=51705



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

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