formula help

ishabir

Board Regular
Joined
Nov 7, 2003
Messages
77
Is there an event in Excel such as ON EXIT of a cell or when moving from a cell
it can calculate a formula.

For example, in cell B8 i want to have =(x*y)-z

I want the formula to be in code and hidden because not everyone should be able
to see it or know it.

Any help much appreciated.

Ishabir
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)

SIXTH SENSE

Well-known Member
Joined
Oct 29, 2003
Messages
1,883
hi!
place your code on the on change event of excel.

here!

<font face=Courier New><SPAN style="color:#00007F">Private</SPAN> <SPAN style="color:#00007F">Sub</SPAN> Worksheet_Change(<SPAN style="color:#00007F">ByVal</SPAN> Target <SPAN style="color:#00007F">As</SPAN> Range)
<SPAN style="color:#007F00">' your code here</SPAN>
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>

This will be executed each time you make an edit in any cell within that worksheet.
 

ishabir

Board Regular
Joined
Nov 7, 2003
Messages
77
thanks for that sixth sense. However, I am having a problem with this line, which keeps on crashing my machine.

Range("B23").Formula = Range("B8").Value / Range("B4").Value

Any ideas?

Thanks,

ishabir
 

SIXTH SENSE

Well-known Member
Joined
Oct 29, 2003
Messages
1,883
Hi!
I works fine in me.
Just make sure that B4 is not zero or else you get an error.

to avoid that paste this before your code.

Code:
On error resume next
Range("B23")= Range("B8").Value / Range("B4").Value
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,152,161
Messages
5,768,539
Members
425,480
Latest member
br400821

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
Top