View Full Version : Looping
Alvinkiang
06-22-2006, 05:30 PM
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
lucas
06-22-2006, 06:32 PM
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
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
Alvinkiang
06-22-2006, 08:28 PM
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
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
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??
Hi
???Perhaps related to
http://vbaexpress.com/forum/showthread.php?t=8514
Tony
Alvinkiang
06-22-2006, 09:12 PM
Hi
???Perhaps related to
http://vbaexpress.com/forum/showthread.php?t=8514
Tony
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..
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
Alvinkiang
06-22-2006, 11:03 PM
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...
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.