与えられた列ヘッダーセットがあり、列ヘッダー名のみがわかっているとします。 カラム名を取得するだけです。たとえば、カラム名 "Text"を検索していて、それがセルAにある場合、Aを結果として返したいのですが、誰かが助けてくれますか?ここで既知の列ヘッダー名で列値を取得する方法
は尖った@newguy私のコード
Sub searchHeader()
columnNamesRow = 1 ' or whichever row your names are in
nameToSearch = "Text" ' or whatever name you want to search for
columnToUse = 0
lastUsedColumn = Worksheets("Sheet1").Cells(1, Worksheets("Sheet1").Columns.Count).End(xlToLeft).Column
For col = 1 To lastUsedColumn
If Worksheets("Sheet1").Cells(columnNamesRow, col).Value = nameToSearch Then
columnToUse = col
End If
Next col
If columnToUse > 0 Then
' found the column you wanted, do your thing here using "columnToUse" as the column index
MsgBox columnToUse
End If
End Sub
ここでこの[関数](http://stackoverflow.com/questions/12796973/function-to-convert-column-number-to-letter)を使用してください。 – newguy
ありがとうございました! –