Go Back   Access World Forums > Microsoft Access Discussion > Macros

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 03-12-2018, 03:30 AM   #1
Sonya810
Newly Registered User
 
Join Date: Mar 2018
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Sonya810 is on a distinguished road
Macro stop working

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").Delete

End With

Sonya810 is offline   Reply With Quote
Old 03-12-2018, 03:33 AM   #2
Ranman256
Newly Registered User
 
Join Date: Apr 2015
Location: KY,USA
Posts: 2,882
Thanks: 0
Thanked 629 Times in 614 Posts
Ranman256 will become famous soon enough
Re: Macro stop working

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.
Ranman256 is offline   Reply With Quote
Old 03-12-2018, 03:44 AM   #3
Sonya810
Newly Registered User
 
Join Date: Mar 2018
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Sonya810 is on a distinguished road
Re: Macro stop working

Oops! I actually need to keep column B, E and I and get rid of everything else up to Column J

Sonya810 is offline   Reply With Quote
Old 03-12-2018, 08:31 AM   #4
dbalargin
Member
 
Join Date: Dec 2002
Location: US
Posts: 37
Thanks: 0
Thanked 0 Times in 0 Posts
dbalargin
Re: Macro stop working

Are you receiving an error message?
dbalargin is offline   Reply With Quote
Old 03-12-2018, 08:33 AM   #5
Sonya810
Newly Registered User
 
Join Date: Mar 2018
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Sonya810 is on a distinguished road
Re: Macro stop working

The problem is solved. There were issues with my files.

Sonya810 is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to stop and autoexec macro Kesh Reports 3 05-23-2012 12:58 PM
build a macro that I can stop waterdamage Excel 11 04-16-2007 09:59 AM
Stop macro using VBA accessman2 Macros 2 02-10-2006 08:01 AM
Stop Macro accessman2 Modules & VBA 2 02-07-2006 04:30 PM
stop macro kingsgambit Macros 0 10-22-2001 08:39 AM




All times are GMT -8. The time now is 06:38 PM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Sponsored Links

How to advertise

Media Kit


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World