Parsing 解析网格线数据并与其他数据进行比较以获得网格范围

Parsing 解析网格线数据并与其他数据进行比较以获得网格范围,parsing,comparison,gridlines,Parsing,Comparison,Gridlines,我这里有一个非常具有挑战性的问题。解决这个问题对我来说是非常重要的,这样我们的部门才能节省数百万美元(因此非常感谢真诚的帮助)。 实际上,我们有两列不同的文本形式的“网格线数据”。e、 g.GL 23.5-24/g。此处23.5-24表示沿X轴的读数,而g表示沿Y轴的研磨。所有这些数据都在一列中。有时,数据不是单个值,而是一组值,例如GL 24-24.7/S-T、GL 25.3-25.5/S-T,有时类似于GL 27/H;27/H.5;26.5/J.5和GL26.5-27.5/L。 现在我在处理

我这里有一个非常具有挑战性的问题。解决这个问题对我来说是非常重要的,这样我们的部门才能节省数百万美元(因此非常感谢真诚的帮助)。 实际上,我们有两列不同的文本形式的“网格线数据”。e、 g.GL 23.5-24/g。此处23.5-24表示沿X轴的读数,而g表示沿Y轴的研磨。所有这些数据都在一列中。有时,数据不是单个值,而是一组值,例如GL 24-24.7/S-T、GL 25.3-25.5/S-T,有时类似于GL 27/H;27/H.5;26.5/J.5和GL26.5-27.5/L。 现在我在处理这些数据时面临两大挑战。 首先,我必须将这些基于文本的数据转换为某种有用且可直接理解的网格线数据,即GL 24-24.7/S-T在一个单元格中应类似于24-24.7,在另一个单元格中应类似于S-T,并清楚指示24-24.7沿X轴,反之亦然。完成此操作后,我必须将此数据与具有相同数据类型的另一列(即GL 24.5/S.5)进行比较。比较应该告诉我比较的网格是否属于主网格(作为一个子集)。 e、 g.如果主网格线为23-25/R-T,第二个网格线为24.5/S,那么第二个网格线肯定位于第一个网格线之下(或介于两者之间)

因此,总体问题是在将文本数据分离到有用的网格中之后,检查其他网格中的第一条网格线。我做了一些临时工作,只是为了得到整个字符串的解析,但无法形成合理的算法来进一步进行

这是我当前解析数据的代码

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)
End With

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

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
Dim strAll()作为字符串
Dim strSNO()作为字符串,Meesam()作为字符串
Dim lastRow为整数,i为整数,newRng为范围,cnt为整数,x为字符串
将a变暗为整数
使用此工作簿。工作表(“数据”)
lastRow=.Range(“A7000”).End(xlUp).Row
雷迪姆街(最后一排)
设置newRng=.Range(“A1:A”和lastRow)
以
对于cnt=LBound(strAll())到UBound(strAll())
strAll(cnt)=新的单元格(cnt+1,1).值
下一个
趁我不在的时候去做
如果(InStr(1,strAll(i),“Element”,vbTextCompare)>0,则
i=i+2
直到InStr(1,strAll(50),“+GL”,vbTextCompare)>0'循环,直到行包含“+”
Meesam=SplitMultiDelims(strAll(i),“/”)
a=0
对于a=LBound(Meesam)到UBound(Meesam)
新偏差(i,a)=最小偏差(a)
下一个
i=i+1
环
如果结束
i=i+1
环
函数IsInside(区域为字符串,矩形为字符串)为布尔值
将部分()设置为字符串
将Line1标注为字符串,Line2标注为字符串,Lx1标注为单个,Ly1标注为单个,Lx2标注为字符串,Ly2标注为字符串
Dim Rect1作为字符串,Rect2作为字符串,Rx1作为单个,Ry1作为单个,Rx2作为字符串,Ry2作为字符串
出错时继续下一步
零件=拆分(替换(区域“,”),“/”)
第1行=零件(0)
第2行=零件(1)
如果InStr(1,第1行,“-”,vbTextCompare)>0,则
零件=拆分(第1行,“-”)
Lx1=零件(0)
Ly1=零件(1)
其他的
Lx1=第1行
Ly1=“0”
如果结束
如果InStr(1,第2行,“-”,vbTextCompare)>0,则
零件=拆分(第2行,“-”)
Lx2=零件(0)
Ly2=零件(1)
其他的
Lx2=第2行
Ly2=0
如果结束
零件=拆分(替换(矩形“,”),“/”)
Rect1=零件(0)
Rect2=零件(1)
如果InStr(1,Rect1,“-”,vbTextCompare)>0,则
零件=拆分(矩形1,“-”)
Rx1=零件(0)
Ry1=零件(1)
其他的
Rx1=Rect1
Ry1=0
如果结束
如果InStr(1,Rect2,“-”,vbTextCompare)>0,则
零件=拆分(矩形2,“-”)
Rx2=零件(0)
Ry2=零件(1)
其他的
Rx2=Rect2
Ry2=0
如果结束
如果Lx1>0,Ly1>0,Lx2>0,Ly2>0,Rx1>0,Ry1>0,Rx2>0,Ry2>0,则
IsInside=Lx1>=Rx1和Lx1=Rx2和Lx2 0和Ly1=0,Lx2>0和Ly2>0,Rx1>0和Ry1>0,Rx2>0和Ry2>0,然后
IsInside=Lx1>=Rx1和Lx1=Rx2和Ly2 0和Ly1=0和Lx2>0和Ly2=0和Rx1>0和Ry1>0和Rx2>0和Ry2>0,然后
IsInside=Lx1>=Rx1和Lx1=Rx2和Lx2 0和Ly1>0和Lx2>0和Ly2>0和Rx1>0和Ry1=0和Rx2>0和Ry2>0,然后
IsInside=0
如果Lx1>0,Ly1=0,Lx2>0,Ly2>0,Rx1>0,Ry1=0,Rx2>0,Ry2>0,则
IsInside=Lx1=Rx1和Lx2>=Rx2和Ly2 0和Ly1=0和Lx2>0和Ly2=0和Rx1>0和Ry1=0和Rx2>0和Ry2>0,然后
IsInside=Lx1=Rx1和Lx2>=Rx2和Lx2 0和Ly1>0和Lx2>0和Ly2>0和Rx1>0,Ry1=0和Rx2>0,Ry2=0,然后
IsInside=0
ElseIf Lx1>0,Ly1=0,Lx2>0,Ly2>0,Rx1>0,Ry1=0,Rx2>0,Ry2=0,则
IsInside=0
ElseIf Lx1>0,Ly1=0,Lx2>0,Ly2=0,Rx1>0,Ry1=0,Rx2>0,Ry2=0,则
IsInside=0
如果Lx1>0和Ly1>0和Lx2>0和Ly2>0和Rx1>0和Ry1>0和Rx2>0和Ry2=0,则
IsInside=0
ElseIf Lx1>0,Ly1=0,Lx2>0,Ly2>0,Rx1>0,Ry1>0,Rx2>0,Ry2=0,则
IsInside=0
ElseIf Lx1>0,Ly1=0,Lx2>0,Ly2=0,Rx1>0,Ry1>0,Rx2>0,Ry2=0,则
IsInside=0
其他的
如果结束
端函数

所以你所要做的就是把网格值放在一个单元格里,把大矩形的值(你必须在其中搜索)放在另一个单元格里,然后使用上面提到的函数

我知道这是一个非常复杂的项目,但我相信有很多专家可以真正管理它。我只需要总体的指导方针,我会照顾自己的项目。ThnxI将非常高兴,即使任何人都可以分享一些一般的想法。我的想法是基于“”值解析数据,以便获得不同的网格数据。然后主要是确定哪个值更高,即B>A等等(仅基于字母表)。在所有这些之后,我可以使用一些比较技术来与我的参考列表进行比较。伙计们,我回来了,带着问题的完整解决方案。我花了将近一个月的时间才找到最终的解决方案。函数如下所示,可以按以下方式使用。单元格A1=坐标(根据t
Function IsInside(Area As String, Rectangle As String) As Boolean

Dim Parts() As String
Dim Line1 As String, Line2 As String, Lx1 As Single, Ly1 As Single, Lx2 As String, Ly2 As String
Dim Rect1 As String, Rect2 As String, Rx1 As Single, Ry1 As Single, Rx2 As String, Ry2 As String

On Error Resume Next

Parts = Split(Replace(Area, " ", ""), "/")
Line1 = Parts(0)
Line2 = Parts(1)

If InStr(1, Line1, "-", vbTextCompare) > 0 Then
 Parts = Split(Line1, "-")
 Lx1 = Parts(0)
 Ly1 = Parts(1)
Else
Lx1 = Line1
Ly1 = "0"
End If

If InStr(1, Line2, "-", vbTextCompare) > 0 Then
 Parts = Split(Line2, "-")
 Lx2 = Parts(0)
 Ly2 = Parts(1)
Else
Lx2 = Line2
Ly2 = 0
End If

Parts = Split(Replace(Rectangle, " ", ""), "/")
Rect1 = Parts(0)
Rect2 = Parts(1)

If InStr(1, Rect1, "-", vbTextCompare) > 0 Then
 Parts = Split(Rect1, "-")
 Rx1 = Parts(0)
 Ry1 = Parts(1)
Else
 Rx1 = Rect1
 Ry1 = 0
End If

If InStr(1, Rect2, "-", vbTextCompare) > 0 Then
 Parts = Split(Rect2, "-")
 Rx2 = Parts(0)
 Ry2 = Parts(1)
Else
 Rx2 = Rect2
 Ry2 = 0
End If

If Lx1 > 0 And Ly1 > 0 And Lx2 > 0 And Ly2 > 0 And Rx1 > 0 And Ry1 > 0 And Rx2 > 0 And Ry2 > 0 Then
 IsInside = Lx1 >= Rx1 And Lx1 <= Ry1 And Lx2 >= Rx2 And Lx2 <= Ry2
ElseIf Lx1 > 0 And Ly1 = 0 And Lx2 > 0 And Ly2 > 0 And Rx1 > 0 And Ry1 > 0 And Rx2 > 0 And Ry2 > 0 Then
 IsInside = Lx1 >= Rx1 And Lx1 <= Ry1 And Lx2 >= Rx2 And Ly2 <= Ry2
ElseIf Lx1 > 0 And Ly1 = 0 And Lx2 > 0 And Ly2 = 0 And Rx1 > 0 And Ry1 > 0 And Rx2 > 0 And Ry2 > 0 Then
 IsInside = Lx1 >= Rx1 And Lx1 <= Ry1 And Lx2 >= Rx2 And Lx2 <= Ry2
ElseIf Lx1 > 0 And Ly1 > 0 And Lx2 > 0 And Ly2 > 0 And Rx1 > 0 And Ry1 = 0 And Rx2 > 0 And Ry2 > 0 Then
 IsInside = 0
ElseIf Lx1 > 0 And Ly1 = 0 And Lx2 > 0 And Ly2 > 0 And Rx1 > 0 And Ry1 = 0 And Rx2 > 0 And Ry2 > 0 Then
 IsInside = Lx1 = Rx1 And Lx2 >= Rx2 And Ly2 <= Ry2
ElseIf Lx1 > 0 And Ly1 = 0 And Lx2 > 0 And Ly2 = 0 And Rx1 > 0 And Ry1 = 0 And Rx2 > 0 And Ry2 > 0 Then
 IsInside = Lx1 = Rx1 And Lx2 >= Rx2 And Lx2 <= Ry2
ElseIf Lx1 > 0 And Ly1 > 0 And Lx2 > 0 And Ly2 > 0 And Rx1 > 0 And Ry1 = 0 And Rx2 > 0 And Ry2 = 0 Then
 IsInside = 0
ElseIf Lx1 > 0 And Ly1 = 0 And Lx2 > 0 And Ly2 > 0 And Rx1 > 0 And Ry1 = 0 And Rx2 > 0 And Ry2 = 0 Then
 IsInside = 0
ElseIf Lx1 > 0 And Ly1 = 0 And Lx2 > 0 And Ly2 = 0 And Rx1 > 0 And Ry1 = 0 And Rx2 > 0 And Ry2 = 0 Then
 IsInside = 0
ElseIf Lx1 > 0 And Ly1 > 0 And Lx2 > 0 And Ly2 > 0 And Rx1 > 0 And Ry1 > 0 And Rx2 > 0 And Ry2 = 0 Then
 IsInside = 0
ElseIf Lx1 > 0 And Ly1 = 0 And Lx2 > 0 And Ly2 > 0 And Rx1 > 0 And Ry1 > 0 And Rx2 > 0 And Ry2 = 0 Then
 IsInside = 0
ElseIf Lx1 > 0 And Ly1 = 0 And Lx2 > 0 And Ly2 = 0 And Rx1 > 0 And Ry1 > 0 And Rx2 > 0 And Ry2 = 0 Then
 IsInside = 0
Else
End If

End Function