Parsing gridline data and comparing with other data to get grid ranges

Meesam

Board Regular
Joined
Nov 23, 2011
Messages
66
Hello Guys,
I got one really challenging problem here. It is very important to solve this problem in order for our department to save millions (so sincere help is deeply appreciated).
Actually we have two different columns of "grid-line data" in text form. e.g. GL 23.5-24 / G. Here 23.5 - 24 represents the reading along X-axis while G represents the grind along Y-axis. All this data is in one column. Sometimes the data is not single value rather a combination of values e.g. GL 24-24.7 / S-T, GL 25.3-25.5 / S-T, and at sometimes it's like GL 27/H;27/H.5;26.5/J.5 and GL26.5-27.5/L.
Now I got two big challenges in working with this data.
First is that I have to convert this text-based data in to some sort of useful and directly understandable grid-line data i.e. GL 24-24.7 / S-T should be like 24 - 24.7 in one cell and S - T in other with clear indication that 24 - 24.7 is along X-axis and vice versa. After I do this then I have to COMPARE this data with another column having same type of data i.e. GL 24.5 / S.5. Comparison should be in a way that it tells me whether or not compared grids fall UNDER (as a subset) of main grid or not.
e.g. If i have main grid-line as 23 - 25 / R - T and I have the second grid is 24.5 / S then surely this second grid falls UNDER (or in between) the first one.

So the overall problem is about checking first grid line in other after separating the text data in useful grids. I did bit of scratch work only to get the parsing of overall strings but unable to form reasonable algorithm to proceed further.

Here is my current code to parse data.
Code:
Option Explicit
Sub DataParsing()

Dim strAll() As String
Dim strSNO() As String, Meesam() As String
Dim lastRow As Integer, i As Integer, newRng As Range, cnt As Integer, x As String
Dim a As Integer

With ThisWorkbook.Sheets("Data")
    lastRow = .Range("A7000").End(xlUp).Row
    ReDim strAll(lastRow)
    Set newRng = .Range("A1:A" & lastRow)
    MsgBox LBound(strAll()) & ":" & UBound(strAll())
End With

    For cnt = LBound(strAll()) To UBound(strAll())
        strAll(cnt) = newRng.Cells(cnt + 1, 1).Value
    Next
    

MsgBox LBound(strAll) & ": " & UBound(strAll) & "i = " & i
Do While i < UBound(strAll)

    If (InStr(1, strAll(i), "Element", vbTextCompare) > 0) Then
        i = i + 2
        Do Until InStr(1, strAll(50), "+GL", vbTextCompare) > 0 'Loop until line includes "+"
            Meesam = SplitMultiDelims(strAll(i), "/")
            a = 0
            'For a = LBound(Meesam) To UBound(Meesam)
             '   newRng.Offset(i, a) = Meesam(a)
            'Next
            i = i + 1
        Loop
    End If
    i = i + 1
Loop

End Sub


Function SplitMultiDelims(Text As String, DelimChars As String) As String()

Dim Pos1 As Long
Dim N As Long
Dim M As Long
Dim Arr() As String
Dim i As Long

If Len(Text) = 0 Then
    Exit Function
End If

If DelimChars = vbNullString Then
    SplitMultiDelims = Array(Text)
    Exit Function
End If

ReDim Arr(1 To Len(Text))

i = 0
N = 0
Pos1 = 1

For N = 1 To Len(Text)
    For M = 1 To Len(DelimChars)
        If StrComp(Mid(Text, N, 1), Mid(DelimChars, M, 1), vbTextCompare) = 0 Then
            i = i + 1
            Arr(i) = Mid(Text, Pos1, N - Pos1)
            Pos1 = N + 1
            N = N + 1
        End If
    Next M
Next N

If Pos1 <= Len(Text) Then
    i = i + 1
    Arr(i) = Mid(Text, Pos1)
End If

ReDim Preserve Arr(1 To i)
SplitMultiDelims = Arr
    
End Function

I really need some expert level help here. Would sincerely appreciate that.
Regards.
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
I will be extremely happy even if anybody can share some general thoughts. My idea is to parse data based on "," values so that I get distinct grid data. Then main thing is to determine which value is higher i.e. B > A and so on (based on alphabets only). After all this i can use some comparison technique to compare with my reference list.
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top