How to reactivate formula in cell with VB following error

bubastisbastet

New Member
Joined
Oct 11, 2008
Messages
11
Hi Forum Members,

I have a spreadsheet in which a particular range (say A1:A100) dynamically changes between 2 states:

1) the "blank" state: range is 100% filled with a pattern, or
2) the "active" state: range is filled to varying degrees with a specific color (in this case color index 37)

So for example, the user may initiate the active state (via VB) and then enter data. if changes were to be made, they would clear all cell contents (via VB) and revert to the "blank" state, re-activate the "active state", and then re-enter their revised data.

I want to utilise a series of "if then" statements that will distinguish (amongst other things) between the 2 states. in order to distinguish the "active" state, I am using the following code (in cell B1 let's say) to determine if any of the cells are colored:

Code:
=colorindexofrange(A1:A100,false,1) (as array formula)
if any cells are colored, it will return "37".

this code is generously supplied by chip pearson here:

http://www.cpearson.com/excel/colors.aspx


so far, so good.

the problem is the following:

if the "blank" state is invoked, B1 will return an error (as it can't recognize pattern). upon re-activating the "active state", the error remains UNTIL the formula is re-calculated by performing select/double click/enter in B1.

I am not able to re-calculate B1 using VB:

Code:
range("b1").select
application.doubleclick

or

range("b1").select
application.calculate

so how can i re-calculate B1 using VB??

Many thanks for any help you guys can offer!!
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.

Forum statistics

Threads
1,224,618
Messages
6,179,917
Members
452,949
Latest member
beartooth91

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