+ Reply to Thread
Results 1 to 4 of 4

Loop help please!

  1. #1
    Forum Contributor Rick_Stanich's Avatar
    Join Date
    11-21-2005
    Location
    Ladson SC
    MS-Off Ver
    Office365
    Posts
    1,167

    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 and check a condition, how do I complete this?

    For code, all i have is the first textbox.

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

    Rick
    Win10, Office 365

  2. #2
    Bob Phillips
    Guest

    Re: 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" <[email protected]>
    wrote in message
    news:[email protected]...
    >
    > 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.ColorIndex = 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
    >




  3. #3
    Forum Contributor Rick_Stanich's Avatar
    Join Date
    11-21-2005
    Location
    Ladson SC
    MS-Off Ver
    Office365
    Posts
    1,167
    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 )

    Maybe I just don't understand loops
    Last edited by Rick_Stanich; 02-28-2006 at 12:10 PM.

  4. #4
    Forum Contributor Rick_Stanich's Avatar
    Join Date
    11-21-2005
    Location
    Ladson SC
    MS-Off Ver
    Office365
    Posts
    1,167
    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.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1