Skip to content

Instantly share code, notes, and snippets.

@kissge
Last active May 3, 2020 14:33
Show Gist options
  • Save kissge/72d58833918cba80a37fdf0f82fc303c to your computer and use it in GitHub Desktop.
Save kissge/72d58833918cba80a37fdf0f82fc303c to your computer and use it in GitHub Desktop.
Excelの全シートをそれぞれCSVエクスポートする
Sub saveSheetsAsCSV()
Dim i As Integer
Dim fName As String
Application.DisplayAlerts = False
For i = 1 To Worksheets.Count
fName = "C:\Users\yk\Downloads\sheet-" & i & ".csv"
ActiveWorkbook.Worksheets(i).SaveAs Filename:=fName, FileFormat:=xlCSVUTF8
Next i
End Sub

使い方

  1. Excelで作業したいブックを開く
  2. Alt + F11
  3. 左のペイン「プロジェクト - VBAProject」で「ThisWorkbook」をダブルクリック
  4. ☝を貼る
  5. ツールバーから「実行」
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment