Calculate Selected cells only.

G

Guest

Hi All,

I am not sure if this is the right forum for a VBA question, but I did not
find a more suitable one.

I have a large workbook that takes a very long time to re-calculate so I am
forced to turn off auto calc while working. However I need to re-calc some
specific cells every time I update their formulas. I have an XLA addin
automatically load that has a sub for calculating ONLY the selected cells
withough re-calc-ing the whole nine yards.

Sub CalcSelected()
Selection.Calculate
End Sub

I am getting errors, I even get an error if I move the sub into a module in
the very spreadsheet I am working on.
Does anyone know how to do this correctly?
Thanks in advance!
Stan
 
G

Guest

Try this...........

Sub ConditionalRecalc()
With Selection
..Calculate
End With
End Sub

Vaya con Dios,
Chuck, CABGx3
 
G

Guest

Chuck,
Thank you for your reply.
I get an error when trying to execute your sub:

Run-time error '1004':
Calculate method of Range class failed


When I hit Debug the
..calculate
line is highlighted.

This is the same error as before. I am fairly new to VBA and probably doing
something silly - but for the life of me can not figure out what it is.
Thanks again!
Stan
 
G

Guest

I dunno, it seems to work ok in my Excel 97. I can even use this variation,
having pre-named a non-contiguious range of cells "MyRange"

Sub ConditionalRecalcOLD()
Dim MyRange As Range
Range("MyRange").Calculate
End Sub

I can only think that if you're using a newer version of Excel, something
might have changed........ Maybe someone else here or in the Programming
newsgroup might be familiar with the problem.

Vaya con Dios,
Chuck, CABGx3
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top