Hi,
I wrote this code, and seems to work as far as the last line of GetTag2, then it throws a value error. I don't seem to be able to access the values in the xVal object:
Function LogBrackets(CheckStr As String, OpBra As String, ClBra As String, Optional Limit As Integer = 0) As Object
Set BraLog = New Collection
OpBraLen = Len(OpBra)
ClBraLen = Len(ClBra)
If Limit = 0 Then
Limit = Len(CheckStr) / 2
End If
BraLog.Add InStr(CheckStr, OpBra)
Debug.Print "Found an OpBra: "; BraLog(BraLog.Count)
If BraLog(1) = 0 Then GoTo DoneLine
For i = 1 To Limit
BraLog.Add InStr(BraLog(BraLog.Count) + OpBraLen, CheckStr, ClBra)
Debug.Print "Loop: "; i; "Found a ClBra: "; BraLog(BraLog.Count)
If BraLog(BraLog.Count) = 0 Then GoTo DoneLine
BraLog.Add InStr(BraLog(BraLog.Count) + ClBraLen, CheckStr, OpBra)
Debug.Print "Loop: "; i; "Found an OpBra: "; BraLog(BraLog.Count)
If BraLog(BraLog.Count) = 0 Then GoTo DoneLine
Next i
DoneLine: 'LogBrackets = BraLog
End Function
Function GetTag2(CheckStr As String, OpBra As String, ClBra As String, Optional Limit As Integer = 0)
Dim xVal As Collection
Set xVal = LogBrackets(CheckStr, OpBra, ClBra)
Debug.Print "so far so good"
Debug.Print xVal.Count
End Function
I was trying to implement something based on this code here:
https://www.mrexcel.com/forum/excel-...-function.html
Bookmarks