+ Reply to Thread
Results 1 to 8 of 8

Macro that disregards blanks when exporting a selected field

  1. #1
    Registered User
    Join Date
    10-30-2013
    Location
    Solihull
    MS-Off Ver
    Excel 2010
    Posts
    4

    Macro that disregards blanks when exporting a selected field

    Hi,

    I have only found one macro that has ever worked near how I want it to, however it exports all the data including the blank rows to csvExport selected field to CSV.txt. Is there a way for it to disregard these when exporting? Also it would be great if the export filename included the date from a cell within my workbook.

    Any help is most gratefully received.

    Thanks in advance..!

    R

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2407 Win 11 Home 64 Bit
    Posts
    24,084

    Re: Macro that disregards blanks when exporting a selected field

    How about deleting the blank rows before you run the export macro

    Please Login or Register  to view this content.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Registered User
    Join Date
    10-30-2013
    Location
    Solihull
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Macro that disregards blanks when exporting a selected field

    Thanks for that Alan..
    My selection has data around it, and the blank cells have formulas, and the selection area is linked to other sheets, so I thought it best to somehow delete the blank rows in the csv export or have a macro to only export rows with values. I require this as I will be uploading the csv to a program that will stop if it gets to a blank row.
    I was unable to get the macro you supplied to work. It said "overflow".. I am a complete novice at this, and appreciate your time & answer.
    Kindest regards
    R

  4. #4
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2407 Win 11 Home 64 Bit
    Posts
    24,084

    Re: Macro that disregards blanks when exporting a selected field

    Did you install the VBA using this method shown below? If you have formulas in cells, then the rows are not blank and will not be deleted.

    A thought: When you export to the CSV file and you open the CSV file, do the "Blank" rows appear without any data or formulas in them? If that is true, then you could run a delete empty row macro on the CSV file before you send it to your third party application.

    How to install your new code
    1. Copy the Excel VBA code
    2. Select the workbook in which you want to store the Excel VBA code
    3. Press Alt+F11 to open the Visual Basic Editor
    4. Choose Insert > Module
    5. Edit > Paste the macro into the module that appeared
    6. Close the VBEditor
    7. Save your workbook (Excel 2007+ select a macro-enabled file format, like *.xlsm)

    To run the Excel VBA code:
    1. Press Alt-F8 to open the macro list
    2. Select a macro in the list
    3. Click the Run button

  5. #5
    Registered User
    Join Date
    10-30-2013
    Location
    Solihull
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Macro that disregards blanks when exporting a selected field

    I have just tried this in the csv export file and it works perfectly.. Many thanks for that.. I don't suppose there is a way of exporting the macro so it is in the csv file along with the data..?

  6. #6
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2407 Win 11 Home 64 Bit
    Posts
    24,084

    Re: Macro that disregards blanks when exporting a selected field

    Probably not, but if you create a personal.xlsb file you can store the macro in that file and will be available to you in any file you open. Here is a link on how to do that.

    http://www.rondebruin.nl/win/personal.htm

    This is how I keep all the macros I use regularly. It is a common practice among experienced Excel users.

    good luck.
    Alan

  7. #7
    Registered User
    Join Date
    10-30-2013
    Location
    Solihull
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Macro that disregards blanks when exporting a selected field

    Great stuff..! Cheers Alan.. You have really helped me out..!

    Thanks

    Ryan

  8. #8
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2407 Win 11 Home 64 Bit
    Posts
    24,084

    Re: Macro that disregards blanks when exporting a selected field

    You are welcome and thankyou for the Reps

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Exporting selected data from Excel to Word
    By xxgirlinbluexx in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-08-2013, 12:22 PM
  2. Exporting selected values into a new CSV file
    By excelbegi in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-14-2012, 10:55 PM
  3. Setting character length of field when exporting
    By mpark1982 in forum Excel General
    Replies: 0
    Last Post: 01-22-2009, 02:14 PM
  4. Exporting memo field to Excel
    By krabople in forum Excel General
    Replies: 1
    Last Post: 02-15-2008, 05:34 AM
  5. Exporting selected data / automation
    By dougb415 in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 09-21-2005, 04:05 PM

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