Hello there,
I have some code - originally kindly given to me from someone here a long time ago.
I need to modify it, I am not very good with VB and have been trying last 2 days without success.
Currently this code searches for text which begins with a < and ends with >
I know it is easy to adjust a single start and end character but I wish to search for more - e.g.. start with <span & ends with span>
I really cannot figure this out if I enter these parameters I get no response back, any help gratefully received.
Thanks
EXISTING CODE
Function TrimCell(rng As Range)
Dim strTemp As String
Dim n As Long
Dim switch As Boolean
For n = 1 To Len(rng)
If Not switch Then
If Mid(rng, n, 1) = "<" Then
strTemp = strTemp & Mid(rng, n, 1)
switch = True
Else
strTemp = strTemp & ""
End If
Else
If Mid(rng, n, 1) = ">" Then
strTemp = strTemp & Mid(rng, n, 1)
switch = False
Else
strTemp = strTemp & Mid(rng, n, 1)
End If
End If
Next
TrimCell = strTemp
End Function
NEW CODE
Function TrimCell(rng As Range)
Dim strTemp As String
Dim n As Long
Dim switch As Boolean
For n = 1 To Len(rng)
If Not switch Then
If Mid(rng, n, 1) = "<span" Then
strTemp = strTemp & Mid(rng, n, 1)
switch = True
Else
strTemp = strTemp & ""
End If
Else
If Mid(rng, n, 1) = "span>" Then
strTemp = strTemp & Mid(rng, n, 1)
switch = False
Else
strTemp = strTemp & Mid(rng, n, 1)
End If
End If
Next
TrimCell = strTemp
End Function
Bookmarks