VBA 查找值所在的列号
目录
Function FindColOfValue(ws As Worksheet, val As Variant, rowNum As Long, startCol As Long)
Dim i As Long
With ws
For i = startCol To .Range(.Cells(startCol, rowNum), .Cells(startCol, rowNum)).CurrentRegion.Columns.Count()
If .Cells(rowNum, i).Value = val Then
FindColOfValue = i
Exit Function
End If
Next
End With
FindColOfValue = -1
End Function