Consulting

Results 1 to 7 of 7

Thread: Looping

  1. #1

    Looping

    hi, i i have 10 data in a col and i want to have a loop to read till the ten col finish and extract specific data name only, how can i mae the loop??? data might increase

  2. #2
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    to use this:
    it is set up now to search column A
    put the search string in cell C1
    don't remember where I came across this. I think its from Johns 1 line find kb entry
    [vba]
    Option Explicit
    Sub GoToFnd()
    Dim c As Range, FirstFound As String
    Set c = Range("A:A").Find(what:=[C1], after:=[A1])
    FirstFound = c.Address
    c.Activate
    Do Until MsgBox("Look for next", vbYesNo) = vbNo
    Set c = Range("A:A").Find(what:=[C1], after:=c)
    If c.Address = FirstFound Then
    MsgBox "No more " & [C1]
    Exit Sub
    End If
    c.Activate
    Loop
    End Sub
    [/vba]
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  3. #3
    Quote Originally Posted by lucas
    to use this:
    it is set up now to search column A
    put the search string in cell C1
    don't remember where I came across this. I think its from Johns 1 line find kb entry
    [vba]
    Option Explicit
    Sub GoToFnd()
    Dim c As Range, FirstFound As String
    Set c = Range("A:A").Find(what:=[C1], after:=[A1])
    FirstFound = c.Address
    c.Activate
    Do Until MsgBox("Look for next", vbYesNo) = vbNo
    Set c = Range("A:A").Find(what:=[C1], after:=c)
    If c.Address = FirstFound Then
    MsgBox "No more " & [C1]
    Exit Sub
    End If
    c.Activate
    Loop
    End Sub
    [/vba]
    i think this loop is searching for a data name in the column... but wat if i have repeat name?? and i dunno how many of it i have as data is too much??

  4. #4

  5. #5
    Quote Originally Posted by acw
    i did... but that was a infinite loop... and if i have only 5 of that name, it will loop all the was till my com can't move... it will add and add and add... the findadd nv matches the findit..

  6. #6
    Hi

    Interesting. Didn't for me.

    Open the 2 attached files. In Alvinkiang, run the macro runform. Enter aa into the textbox, then press the button. The 4 entries for aa should be brought across from Alvinkiang2.xls

    Tony

  7. #7
    Quote Originally Posted by acw
    Hi

    Interesting. Didn't for me.

    Open the 2 attached files. In Alvinkiang, run the macro runform. Enter aa into the textbox, then press the button. The 4 entries for aa should be brought across from Alvinkiang2.xls

    Tony
    hmmm... i think something is wrong with wat i have done...
    Sorry for that tony...

Posting Permissions

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