Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Delete all files except...

I would like to make a little button that, wehn pressed, would delete
all files in a directory except for the ones that I specidy. It would
be nice if I could display a listbox and check the ones that I wanted
to delete but for now, I can just hardcode the files to keep. I can
populate the listbox but can't figure out how to delete the ones not
selected.

Anyone have any ideas on how to do this?
Thanks in advance,
David

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Delete all files except...

David,

It would
be nice if I could display a listbox and check the ones that I wanted
to delete


Here's a macro that will delete the files that you choose:

Sub DeleteMultipleUserSelectedFiles()
Dim FileArray As Variant
Dim i As Integer

FileArray = Application.GetOpenFilename(MultiSelect:=True)
If IsArray(FileArray) Then
For i = LBound(FileArray) To UBound(FileArray)
Kill FileArray(i)
Next i
End If
End Sub

HTH,
Bernie
MS Excel MVP


"David Johnston" wrote in message
oups.com...
I would like to make a little button that, wehn pressed, would delete
all files in a directory except for the ones that I specidy. It would
be nice if I could display a listbox and check the ones that I wanted
to delete but for now, I can just hardcode the files to keep. I can
populate the listbox but can't figure out how to delete the ones not
selected.

Anyone have any ideas on how to do this?
Thanks in advance,
David



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to delete archived files Bob English[_2_] Excel Discussion (Misc queries) 1 January 29th 09 03:42 AM
How to delete archived tmp files Bob English Excel Discussion (Misc queries) 0 December 19th 08 08:32 PM
Delete files with VBA BEEJAY Excel Programming 1 May 12th 06 07:01 PM
Delete Files with less than 2 sheets BillyRogers Excel Programming 2 February 22nd 06 04:39 PM
Delete All Files in a folder Michael Smith Excel Programming 1 June 8th 05 05:32 PM


All times are GMT +1. The time now is 04:58 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"