ElGatito
06-03-2010, 02:06 PM
Hi Guys,
Sorry in advance, but on that one, I really can't figure it out. Yes, I am quite new to basic, and the fix will probably be simple to do. but here's the thing.
I just need to have a count different links in the different folders of a webpage. So I have two lists, one with the URLs, and one with the subfolders.
i crafted a small code to compare and count the number of time the two list have a similar element (Folders are surrounded by *) Each time the two list are the same Count goes plus one.
Here's the thing, it works great when done individually, but when I try to Loop it, or use For, then it take the first result and spreads it on all subfolders
So what's wrong with my Code?
Sub counturlsComplex()
Dim Target As String
Dim Compared As String
Dim Count As Integer
Dim Row As Single
Dim StartRow As Single
Dim EndRow As Single
Row = 1
StartRow = 1
For i = 1 To 215
Do Until IsEmpty(Cells(StartRow, 1))
Target = Cells(Row, 6)
Compared = Cells(StartRow, 1)
If Compared Like Target Then
Count = Count + 1
End If
StartRow = StartRow + 1
Loop
Cells(Row, 5) = Count
Row = Row + 1
Next i
End Sub
And yes If you see some elements which aren't used, its because I tried to tweak it like crazy all day.
Thanks a lot in advance, you wouldn't believe how much this would help me. (Even a tip or two to go in the good direction)
Sorry in advance, but on that one, I really can't figure it out. Yes, I am quite new to basic, and the fix will probably be simple to do. but here's the thing.
I just need to have a count different links in the different folders of a webpage. So I have two lists, one with the URLs, and one with the subfolders.
i crafted a small code to compare and count the number of time the two list have a similar element (Folders are surrounded by *) Each time the two list are the same Count goes plus one.
Here's the thing, it works great when done individually, but when I try to Loop it, or use For, then it take the first result and spreads it on all subfolders
So what's wrong with my Code?
Sub counturlsComplex()
Dim Target As String
Dim Compared As String
Dim Count As Integer
Dim Row As Single
Dim StartRow As Single
Dim EndRow As Single
Row = 1
StartRow = 1
For i = 1 To 215
Do Until IsEmpty(Cells(StartRow, 1))
Target = Cells(Row, 6)
Compared = Cells(StartRow, 1)
If Compared Like Target Then
Count = Count + 1
End If
StartRow = StartRow + 1
Loop
Cells(Row, 5) = Count
Row = Row + 1
Next i
End Sub
And yes If you see some elements which aren't used, its because I tried to tweak it like crazy all day.
Thanks a lot in advance, you wouldn't believe how much this would help me. (Even a tip or two to go in the good direction)