Macro stop working (1 Viewer)

Sonya810

Registered User.
Local time
Today, 05:42
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
 

Ranman256

Well-known member
Local time
Today, 08:42
Joined
Apr 9, 2015
Messages
4,339
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.
 

Sonya810

Registered User.
Local time
Today, 05:42
Joined
Mar 8, 2018
Messages
22
Oops! I actually need to keep column B, E and I and get rid of everything else up to Column J
 

Sonya810

Registered User.
Local time
Today, 05:42
Joined
Mar 8, 2018
Messages
22
The problem is solved. There were issues with my files.
 

Users who are viewing this thread

Top Bottom