+ Reply to Thread
Results 1 to 8 of 8

Kill .xlxs in a folder path cell

  1. #1
    Registered User
    Join Date
    03-17-2018
    Location
    Italy
    MS-Off Ver
    2013
    Posts
    26

    Kill .xlxs in a folder path cell

    Hi,

    I have this code to kill all .xlxs file in a folder

    Please Login or Register  to view this content.
    It's possibile to substitute C:\Mytemplate with a path in a cell (eg: "A1")?

    Thx in advance!

  2. #2
    Forum Expert
    Join Date
    12-15-2009
    Location
    Chicago, IL
    MS-Off Ver
    Microsoft Office 365
    Posts
    3,177

    Re: Kill .xlxs in a folder path cell

    Just substitute the text with a cell range.
    Kill Thisworkbook.worksheets("Insert your worksheet name").Range("A1").value

  3. #3
    Registered User
    Join Date
    03-17-2018
    Location
    Italy
    MS-Off Ver
    2013
    Posts
    26

    Re: Kill .xlxs in a folder path cell

    I've tried this:
    Please Login or Register  to view this content.
    but it doesn't work. Where is the mistake?

  4. #4
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,014

    Re: Kill .xlxs in a folder path cell

    .
    Are you attempting to delete (Kill) a workbook whose extension is .xlsx ..... or are you attempting to clear a range of cells on a worksheet ?

    If it is deleting all workbooks in a specific folder ... as designated by the path located in cell "A1" .... then :

    Please Login or Register  to view this content.
    In cell A1 your path would look something like this :

    Please Login or Register  to view this content.
    Be certain to have the last backwards slash at the end of the path " \ ". In this example, I placed a folder on the desktop with several .xlsx workbooks. The folder name was "New folder", my computer name is "My".

  5. #5
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: Kill .xlxs in a folder path cell

    Or you can add a check.
    Please Login or Register  to view this content.
    Also it's not .xlxs but .xlsx
    Last edited by bakerman2; 03-18-2018 at 05:15 AM. Reason: Code tweak.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  6. #6
    Registered User
    Join Date
    03-17-2018
    Location
    Italy
    MS-Off Ver
    2013
    Posts
    26

    Re: Kill .xlxs in a folder path cell

    It's works! Thank you, everybody!

  7. #7
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,014

    Re: Kill .xlxs in a folder path cell

    .
    You are welcome. Bakerman : thanks for the suggestion.

  8. #8
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: Kill .xlxs in a folder path cell

    Glad to help. thanks for rep.

+ 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. IF(CELL=Folder Path)
    By Dr34m in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-28-2016, 07:46 AM
  2. [SOLVED] Find folder path for string in cell
    By efarkouh in forum Excel Programming / VBA / Macros
    Replies: 21
    Last Post: 07-26-2016, 09:25 AM
  3. How to validate an input dat folder/directory path whether the path has any spaces
    By mahendra.asapu in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-21-2015, 02:39 AM
  4. [SOLVED] Kill macro if no sheets in folder
    By Crispy85 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-17-2015, 07:32 AM
  5. [SOLVED] Kill all files which are located in the spesific folder
    By HerryMarkowitz in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-11-2015, 08:47 AM
  6. Code to list the folder path and sub folder path of a specific file
    By kalai1587 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-13-2013, 03:51 AM
  7. Kill all non excel files in folder
    By uncleslinky in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-05-2012, 11:17 AM

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