unote 書けば書くほどに

CSVファイルをインポート

Sub CopyAndImportCSV()
Dim sourceFolder As String
Dim sourceFileName As String
Dim destinationPath As String
Dim destinationWorkbook As Workbook
Dim newWorksheet As Worksheet

' サーバー上のAフォルダーのパスを設定
sourceFolder = "\\10.30.33.22\A\"

' CSVファイル名を設定
sourceFileName = "outputSQL.csv"

' コピー元のファイルのパスを取得
sourceFilePath = sourceFolder & sourceFileName

' 起動中のABC.xlsmのワークブックオブジェクトを取得
Set destinationWorkbook = ThisWorkbook

' コピー先のワークシートを作成し、CSVファイルをインポート
Set newWorksheet = destinationWorkbook.Sheets.Add(After:=destinationWorkbook.Sheets(destinationWorkbook.Sheets.Count))
newWorksheet.Name = "リスト" ' ワークシート名を"リスト"に変更

' CSVファイルを新しいワークシートにインポート
With newWorksheet.QueryTables.Add(Connection:="TEXT;" & sourceFilePath, Destination:=newWorksheet.Range("A1"))
.TextFileParseType = xlDelimited
.TextFileCommaDelimiter = True
.Refresh
End With

' インポートが完了したらメッセージを表示
MsgBox "CSVファイルのインポートが完了しました。", vbInformation
End Sub