![]()
Option Explicit Sub ExportToCSV() Dim fPATH As String, LR As Long Dim ws As Worksheet fPATH = ThisWorkbook.Path & Application.PathSeparator Application.ScreenUpdating = False For Each ws In ThisWorkbook.Worksheets With ws If ws.Name Like "Scenario*" Then .AutoFilterMode = False .Rows("5:5").AutoFilter Field:=1, Criteria1:="<>" LR = .Range("A" & .Rows.Count).End(xlUp).Row If LR > 5 Then .Range("A5:F" & LR).Copy Sheets.Add Range("A1").PasteSpecial xlPasteValuesAndNumberFormats ActiveSheet.Move Application.DisplayAlerts = False ActiveWorkbook.SaveAs fPATH & ws.Name & ".csv", FileFormat:=xlCSV, CreateBackup:=False ActiveWorkbook.Close False MsgBox "Export file done: " & fPATH & ws.Name & ".csv" Else MsgBox "No rows with data found to export" End If .AutoFilterMode = False End If End With Next ws Application.ScreenUpdating = True End Sub
If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.
Bookmarks