LoginSignup
0
0

あwd

Last updated at Posted at 2024-06-19

Sub SaveThirdSheetAsCSV()
Dim ws As Worksheet
Dim filePath As Variant

' 3番目のシートを取得
Set ws = ThisWorkbook.Sheets(3)

' 「名前をつけて保存」ダイアログを表示し、ファイルパスを取得
filePath = Application.GetSaveAsFilename(ws.Name & ".csv", "CSV Files (*.csv), *.csv")

' キャンセルが押された場合、処理を終了
If filePath = False Then Exit Sub

' シートをCSV形式で保存
ws.Copy
With ActiveWorkbook
    .SaveAs Filename:=filePath, FileFormat:=xlCSV
    .Close SaveChanges:=False
End With

MsgBox "シートがCSV形式で保存されました。", vbInformation

End Sub

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0