I found a work around for the problem above by extracting my link from the left hand side of the string instead of the right. I could now extract the 2nd, 3rd, 4th link in a cell quite easily (as long as non of the linked cells are ranges!), by counting where each : is and trunkating the string at that value.
The problem now is this is becoming a massive proccessor drain with all the loops. I'm lucky enough to be on a top spec core2duo machine, but even so it takess a good 3 mins of locked up pc to generate the results. Thats without extracting the multiple links in the cells.
Is there anyway to speed this up?:
Sub LinkList()
Dim SearchRange As Range
Dim FoundCells As Range
Dim FoundCell As Range
Dim CompareLikeString As String
Dim SearchOrder As XlSearchOrder
Dim MatchCase As Boolean
Dim OutRng As Range
Dim Orisht As Worksheet
Dim stringform As String
Dim stringform2 As String
Dim sform3 As String
Dim rscut As String
Dim Rsf As String
Set Orisht = Worksheets("LinkList")
Set OutRng = Orisht.Range("A65536")
For Each Worksheet In Worksheets
With Worksheet
Select Case Worksheet.Name
Case "LinkList"
GoTo nxtwks
Case "RefList"
GoTo nxtwks
End Select
End With
'search in this range in search worksheet
Set SearchRange = Worksheet.Range("A1:BM3000")
CompareLikeString = "*[[]*[]]*"
SearchOrder = xlByRows
MatchCase = True
'find matching cells
Set FoundCells = WildCardMatchCells(SearchRange:=SearchRange, CompareLikeString:=CompareLikeString, _
SearchOrder:=SearchOrder, MatchCase:=MatchCase)
If FoundCells Is Nothing Then
'MsgBox "No cells in this worksheet" --Not in use
Else
For Each FoundCell In FoundCells
stringform = FoundCell.Formula
coloncount = 0
'trim off left up to ":" -2
For x = 1 To 20
Rsf = Left(stringform, x)
rscut = Right(Rsf, 1)
If rscut <> ":" Then GoTo Nxt2:
stringform2 = Right(stringform, Len(stringform) - (x - 2))
'coloncount = coloncount + 1
'If coloncount > 1 Then MsgBox coloncount & FoundCell.Address & stringform
'could be used to extract next occurance of : and next etc colon count > 1 means more than one link
Nxt2:
Next x
'trim from right up to "'"
For x = 1 To 150
Rsf = Left(stringform2, x)
rscut = Right(Rsf, 1)
If rscut <> "!" Then GoTo Nxt:
sform3 = Left(stringform2, x - 2)
Nxt:
Next x
' MsgBox sform3
If Application.WorksheetFunction.CountIf(Worksheets("LinkList").Range("A1:A65536"), sform3) > 0 Then GoTo skip
OutRng.End(xlUp).Offset(1, 0).Value = _
sform3
skip:
Next FoundCell
End If
nxtwks:
Next Worksheet
End Sub
Bookmarks