Macro stop working

Sonya810

Registered User.
Local time
Yesterday, 18:04
Joined
Mar 8, 2018
Messages
22
I created a macro to loop through a folder and format all the excel files in that folder, but the formatting part isn't working any longer. It worked fine on Friday. It's suppose to delete certain columns and rows:


'Loop through each Excel file in folder
Do While myfile <> ""



'Set variable equal to opened workbook
Set wb = Workbooks.Open(fileName:=mypath & myfile)


'Ensure Workbook has opened before moving on to next line of code
' DoEvents


With Worksheets("mdballsearch")
.Rows("1:5").Delete
.Columns("A:A").Delete
.Columns("B:B").Delete
.Columns("C:C").Delete
.Columns("E:E").Delete
.Columns("D:D").Delete

End With
 
why not 1 statement:
Code:
.Columns("A:D").Delete    'a-d  ...stupid emoticons

your 5 statements could be trouble....
deleting A, then makes B the new A
then you delete B, (is this the Old B when you had A, or the new B, that used to be C?)

if you delete them all at once , you know what A,b,c,d is getting removed.
 
Oops! I actually need to keep column B, E and I and get rid of everything else up to Column J
 
The problem is solved. There were issues with my files.
 

Users who are viewing this thread

Back
Top Bottom