How to Kill File With Different Location

SunnyAlv

Board Regular
Joined
May 23, 2023
Messages
248
Office Version
  1. 365
Platform
  1. Windows
Hi guys can u help with this problem :)

i just want to kill/Delete File with Loop but i get eror syntax

this my VBA Code :

Sub KILLEachFileWithDiffLocation()

Dim i As Integer

For i = 1 To Application.CountA(Range("I:I"))

ActiveSheet.UsedRange.AutoFilter 9, Range("I" & i).Value


Kill i


Next i


MsgBox "Done"

End Sub

Column I fill with File Location

Thanks
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Why do you have a filter line in the code?
Do all of the files 100% exist or could some be missing?
Which line do you get the error on?
 
Upvote 1
Why do you have a filter line in the code?
Do all of the files 100% exist or could some be missing?
Which line do you get the error on?

thanks for the feed back, i found what i want (CASE CLOSED)

Why do I use filters in VBA?

because when the code runs it will filter the existing values, so I know that when it errors, the filter will stop at one location, and I know that that location has a problem :)
 
Upvote 0
That's good news, could you share here what you found as it may help others that stumble upon your post here in the future?
 
Upvote 0
That's good news, could you share here what you found as it may help others that stumble upon your post here in the future?
yea no problem, it's actually a very simple code to display

I filtered column i and copied it to column "J2", and killed "J2", and repeated it until it finished / error

VBA Code:
Sub KILLEachFileWithDiffLocation()
  Dim i As Integer

  For i = 1 To Application.CountA(Range("I:I"))
    ActiveSheet.UsedRange.AutoFilter 9, Range("I" & i).Value
    Range("I" & i).Copy Range("J2")
    Kill Range("J2").Value
  Next i
  MsgBox "Done"
End Sub
 
Last edited by a moderator:
Upvote 0
Solution
@SunnyAlv
When posting vba code in the forum, please use the available Code tags (not Quote tags). It makes your code much easier to read/debug & copy. My signature block below has more details. I have added the tags for you in post #5 this time.
 
Upvote 1

Forum statistics

Threads
1,215,386
Messages
6,124,628
Members
449,176
Latest member
Dazjlbb

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top