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

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
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.
 
Upvote 0
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
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,222,195
Messages
6,164,514
Members
451,900
Latest member
lamski

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