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.
I really need some expert level help here. Would sincerely appreciate that.
Regards.
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.