Something about this code is making Excel Freeze

Trikageon

Board Regular
Joined
Apr 29, 2010
Messages
51
Hey all! I think it might have something to do with the subsequent calculating, but this code seems to be the culprit when it comes to making my Excel seemingly freeze:

Dim rng As Range

With ActiveSheet.Range("E12:E600")
Set rng = .Find(What:="Total", LookAt:=xlWhole, LookIn:=xlValues)

If Not rng Is Nothing Then
Do
rng.FormulaR1C1 = "=SUMIF(C15,""Total""&R[-2]C[7],C7)"
Set rng = .FindNext(rng)
Loop While Not rng Is Nothing
End If
End With
With ActiveSheet.Range("F12:F600")
Set rng = .Find(What:="Total", LookAt:=xlWhole, LookIn:=xlValues)

If Not rng Is Nothing Then
Do
rng.FormulaR1C1 = "=SUMIF(C15,""Total""&R[-2]C[6],C8)"
Set rng = .FindNext(rng)
Loop While Not rng Is Nothing
End If
End With


How do I make this not slow everything down to a crawl? Thanks in advance?
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Thanks for your reply! When I do that I get an error that says, "Compile Error: Variable not defined" and it points to "rng ="
 
Upvote 0
Code:
with ActiveSheet.columns(5)
   .autofilter 1,"Total"
   for each cl in .offset(1).specialcells(xlcelltypevisible)
     cl="=SUMIF(C15,""Total""&R[-2]C[7],C7)"
   next
   .autofilter
End with
 
with ActiveSheet.columns(6)
   .autofilter 1,"Total"
   for each cl in .offset(1).specialcells(xlcelltypevisible)
     cl="=SUMIF(C15,""Total""&R[-2]C[6],C8)"
   next
   .autofilter
End with
 
Upvote 0
SNB - I'm getting the same "Variable not defined" error pointing to "c1"

Aaron - No, I'm having issues with freezing - the errors I'm mentioning are caught by VBA before I can even run the macro. If I didn't make any of the modifications graciously suggested by these users and ran it as-is, it would freeze.
 
Upvote 0
SNB - I'm getting the same "Variable not defined" error pointing to "c1"

If you get that error it means you have "Option Explicit" specified at the top of your code and you have not dimensioned the variable Cl. From the looks of how you're using it, Cl is maybe a cell and should be dimensioned as a Range in your code.

Dim Cl as Range
 
Upvote 0

Forum statistics

Threads
1,223,714
Messages
6,174,052
Members
452,542
Latest member
Bricklin

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