Results 1 to 12 of 12

Export to CSV rows populated

Threaded View

  1. #8
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Export to CSV rows populated

    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.
    Last edited by JBeaucaire; 04-19-2014 at 07:16 PM. Reason: Corrected naming method.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Printing populated rows only
    By pbutche in forum Excel General
    Replies: 8
    Last Post: 02-07-2014, 06:22 PM
  2. [SOLVED] Trying to write a Loop to perform calculations within blank rows between populated rows
    By ObliviousAmI in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 01-15-2014, 06:35 PM
  3. [SOLVED] Counting populated rows
    By Journeyman3000 in forum Excel Formulas & Functions
    Replies: 14
    Last Post: 11-19-2013, 10:26 AM
  4. How do I export populated cells to a TXT file
    By Tworsey in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-18-2011, 10:55 AM
  5. how to count populated rows?
    By Ryan Cain in forum Excel - New Users/Basics
    Replies: 4
    Last Post: 08-12-2005, 12:05 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1