OK、私は出てくるすべてのオプションを読んだと思いますが、すでに回答されているものからの回答は得られていません.
私がやろうとしていることは次のとおりです。
固定 (62) 見出しを持つマスター WorkBook から、ファイル (.csv) を開くことができるマクロ/VBA を実行できます。このファイルから列を取得し、マスター シートのそれぞれのヘッダーの下に配置します。
.csv ファイルには、メイン ファイルと一致する列ヘッダーが確実に含まれますが、同じ順序ではない場合があります。
どうぞよろしくお願いいたします。
ニック
これは私がこれまで助けてきたコードです...
Sub CopyCSV()
'' Find out how many rows are on the CSV sheet
LRCSV = Sheet1.UsedRange.Rows.Count
'' Find out how many columns are on the Data sheet
LCData = Sheet2.UsedRange.Columns.Count
For x = 2 To LRCSV
'' Find the last row and add one to get the first blank row
LRData = Sheet2.UsedRange.Rows.Count + 1
Sheet2.Activate
'' Finds the columns by the headers
If FirstN = "" Then
For y = 1 To LCData
If Cells(1, y).Value = "First Name" Then FirstN = y
If Cells(1, y).Value = "Surname" Then SurN = y
If Cells(1, y).Value = "Email" Then Email = y
If Cells(1, y).Value = "Telephone Number" Then TelN = y
Next y
End If
Sheet1.Activate
Sheet2.Cells(LRData, FirstN).Value = Sheet1.Cells(x, "A").Value
Sheet2.Cells(LRData, SurN).Value = Sheet1.Cells(x, "B").Value
Sheet2.Cells(LRData, Email).Value = Sheet1.Cells(x, "C").Value
Sheet2.Cells(LRData, TelN).Value = Sheet1.Cells(x, "D").Value
Next x
End Sub
私が苦労している列セクションによる検索...