【EXCEL】【VBA】处理GI Log获得Surf格式的CONTOUR DATA

data source1: BH coordination table

data source2:BH layer table

image-20250211221032901

process 1:Collect BH List To Layer Table

Sub FindBHForAllLayers()
    Dim ws As Worksheet
    Dim wsTarget As Worksheet
    Dim resultRow As Long
    Dim col As Long, targetCol As Long
    Dim lastCol As Long
    Dim layerName As String
    
    Set ws = ThisWorkbook.Sheets("Layer summary")
    Set wsTarget = ThisWorkbook.ActiveSheet
    lastCol = ws.Cells(1, ws.Columns.Count).End(xlToLeft).Column
    
    ' 清除之前的结果
    wsTarget.Range("C2:ZZ50").ClearContents
    
    ' 遍历每个可能的layer起始列(B,G,L...)
    For targetCol = 2 To lastCol Step 5
        layerName = wsTarget.Cells(1, targetCol).Value
        If Not IsEmpty(layerName) Then
            resultRow = 2 '每个layer从第2行开始填写
            
            ' 在Layer summary中搜索这个layer
            For col = 1 To lastCol Step 5
                If Not IsEmpty(ws.Cells(1, col)) Then
                    ' 检查该组中的Description列是否包含当前layer
                    Dim rng As Range
                    Set rng = ws.Range(ws.Cells(1, col + 3), ws.Cells(50, col + 3))
                    
                    If Not IsError(Application.Match(layerName, rng, 0)) Then
                        ' 写入到layer名称的右边一列
                        wsTarget.Cells(resultRow, targetCol + 1).Value = ws.Cells(1, col).Value
                        resultRow = resultRow + 1
                    End If
                End If
            Next col
        End If
    Next targetCol
End Sub

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

hmywillstronger

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值