Macro freezing worksheet

tarmand

Board Regular
Joined
Jul 11, 2002
Messages
197
I have about ten worksheets that I update every month. They are all the same but for different projects. They all have the same 7 macros in them. They have worked fine for about a year, but now when I run one of the macros, it freezes Excel for about 15-20 minutes. When I look at the task manager, it shows that Excel is running so I just wait and it always eventually unfreezes. Any ideas as to what is wrong? This happens when I run that macro on all of the worksheets.
 

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.
tarmand

Would it be possible to post the macro code on the board?
 
Upvote 0
Here it is:

Sub Datechange()
Range("$b$2:$b$65536").Select
For Each c In Selection
c.Value = Right(c.Value, 4) & "-" & Mid(c.Value, 2, 2)
Next c
End Sub
 
Upvote 0
Hi tarmand,

can I ask why it's necessary to fill values in column B for so many cells? Surely the required amount of entries is going to be less than 65,535 cells worth, isn't it?

When doing a loop like this you may wish to switch off calculation before processing and reinstate it afterwards. See the Application.Calculation command in VBA help.
 
Upvote 0
Glenn,

I just did it to the end of the worksheet since I never know how many rows I will have. It is usually less than 10,000 rows so I could change it to that. Do you think that would help? What confuses me is that it has always worked in a matter of seconds in the past and just in the last two days has begun to give me problems.

Thanks,
Tammie
 
Upvote 0
Give this code change a try. It's dynamic and knows what the last populated cell in Column B is, so you don't do the entire column.

Code:
Sub Datechange() 
Dim c as range

For Each c In range("B2",range("B"&activesheet.rows.count).end(xlup))
c.Value = Right(c.Value, 4) & "-" & Mid(c.Value, 2, 2) 
Next c 
End Sub

As far as what is cause the delay now, did you add new formula's, maybe a filter? These kind of things may cause a slow down.

HTH
Cal
 
Upvote 0
Wow, that worked. It ran the macro in less than a second. I don't think I changed anything in the reports, but others do have access to the reports and I don't know what they may have done.

Thanks!
 
Upvote 0

Forum statistics

Threads
1,214,426
Messages
6,119,417
Members
448,895
Latest member
omarahmed1

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