Macro Going Slow

Jared_Jones_23

New Member
Joined
Jun 24, 2011
Messages
34
Hello I have a macro that opens another workbook and deletes rows based on specified criteria. The code that deletes the rows works fine but runs extremely slow. When I step through it my self it seems to work relatively quick but it gets caught up when its running. Here is the sub program that does the deleting. Any suggestions are appreciated thank you.
Jared

Sub delbrows2(fr, cse, delcnt)
Dim r As Integer
Application.ScreenUpdating = False
For r = Cells(rows.Count, 13).End(xlUp).End(xlUp).Row To fr Step -1 'For r = 1000 To 1 Step -1
If Cells(r, 13) <> cse Then
rows(r).Delete
'delcnt = delcnt + 1
End If
Next r
Application.ScreenUpdating = True
End Sub
 
Well. It's working on mine.
I have XL2007 on Windows Vista 32-bit.

What version you using and how are you copying it? (fromn spreadsheet, or macro?)
 
Upvote 0

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
I am using excel 2007 as well. I am copying from a spread sheet using the macro. In the Macro it opens another workbook, filters it based on criteria, then should copy the filtered cells back to the original sheet with the macro, then the macro closes that workbook. For some reason when I copy it it copies everything.
 
Upvote 0
Well, if you tried by now, you will notice the excel will allow you to copy unhidden cells from the spreadsheet.
And if you have found out that trick, you will have noticed that you will need to use a macro recorder to record your action.

The code would look something like this:
Code:
Selection.SpecialCells(xlCellTypeVisible).Copy

I read from somewhere that SpecialCells() slows the code down and there is another alternative for this but I can't seem to dig it out. So, use this for now :P
 
Upvote 0

Forum statistics

Threads
1,223,231
Messages
6,170,884
Members
452,364
Latest member
springate

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