+ Reply to Thread
Results 1 to 11 of 11

macro to delete all CSV files on my desktop desktop folders and and its subfolders

  1. #1
    Forum Contributor
    Join Date
    02-11-2014
    Location
    mauritius
    MS-Off Ver
    MS365
    Posts
    1,086

    macro to delete all CSV files on my desktop desktop folders and and its subfolders

    Looking a macro to del all CSV files on my desktop, desktop folders and and its subfolders only

    Thanks if anyone can assist

  2. #2
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: macro to delete all CSV files on my desktop desktop folders and and its subfolders

    Hello
    Try this code
    Please Login or Register  to view this content.
    < ----- Please click the little star * next to add reputation if my post helps you
    Visit Forum : From Here

  3. #3
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: macro to delete all CSV files on my desktop desktop folders and and its subfolders

    Hello Yasser,

    Your code does not prevent searching system folders on the desktop. Folders like "Computer", "Documents", etc. This code will.

    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  4. #4
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: macro to delete all CSV files on my desktop desktop folders and and its subfolders

    Thanks a lot Mr. Leith for the code
    I tested it and got error 91 at this line
    Please Login or Register  to view this content.

  5. #5
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: macro to delete all CSV files on my desktop desktop folders and and its subfolders

    Hello Yasser,

    Sorry, I made a typo. oFile should be oFolder. This is the corrected code...
    Please Login or Register  to view this content.

  6. #6
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: macro to delete all CSV files on my desktop desktop folders and and its subfolders

    Now it is perfect and awesome Mr. Leith
    God bless you and my kind regards for you

  7. #7
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: macro to delete all CSV files on my desktop desktop folders and and its subfolders

    Hello Yasser,

    Thank you for catching my mistake.

    While the File Scripting Object does a lot of functions well, there are somethings it can not do. The Shell object is a bit more complicated but has very few limitations when handling files and folders.

  8. #8
    Forum Contributor
    Join Date
    02-11-2014
    Location
    mauritius
    MS-Off Ver
    MS365
    Posts
    1,086

    Re: macro to delete all CSV files on my desktop desktop folders and and its subfolders

    Hi Leith

    Nice piece of code , pretty fast for 1000 csv files here and there on desktop

    Save me from a weekly tedious task, thank you for effort and time

    But last question what line should I change instead of desktop but my documents

  9. #9
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: macro to delete all CSV files on my desktop desktop folders and and its subfolders

    Hello JEAN1972,

    Here is the revised Module code. You have two choices. You can either use the added constant MyDocuments or use the folder picker. Both options are included.
    Delete all code in the existing VBA Module and replace it with the code here.

    Please Login or Register  to view this content.
    Option 1
    Please Login or Register  to view this content.
    Option 2
    Please Login or Register  to view this content.

  10. #10
    Forum Contributor
    Join Date
    02-11-2014
    Location
    mauritius
    MS-Off Ver
    MS365
    Posts
    1,086

    Re: macro to delete all CSV files on my desktop desktop folders and and its subfolders

    Thank you Leith

    Works a charm

  11. #11
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: macro to delete all CSV files on my desktop desktop folders and and its subfolders

    Hello JEAN1072,

    You're welcome.

+ 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. [SOLVED] macro to copy files a folder and consolidate in master workbook on desktop
    By JEAN1972 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-01-2016, 01:27 AM
  2. [SOLVED] Macro to Copy and paste folders and subfolders without files in it
    By Madhut in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-07-2016, 01:47 PM
  3. [SOLVED] Need A Macro That Automaticly searches files in desktop to find .dwg file to hyperlink too
    By Eaaron in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-09-2015, 04:49 PM
  4. Needs macro to copy excel files from folders, subfolders to new folder
    By genetist in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-08-2014, 08:53 AM
  5. [SOLVED] Macro to open folder on desktop and certain files within
    By hutch94 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 08-05-2014, 11:01 AM
  6. Replies: 0
    Last Post: 01-08-2014, 11:01 AM
  7. Macro Code to Encrypt Multiple Excel Files in Folders and Subfolders
    By ali_1989 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-04-2014, 12:53 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