Funtion and Cell

H

henpat

Good morning/afternoon

I need to execute a function only when the cell "B4" change of value.
How can I do it?
Thanks in advanced
(Office 2003)

henpat
 
N

Norman Jones

Hi Henpat,

Try something like:

'=================>>
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim rng As Range

Set rng = Range("B4")
If Not Intersect(rng, Target) Is Nothing Then
'Do something, e.g.:
MsgBox "Hi!"
'or:
Call MyMacro
End If
End Sub
'<<================

This is worksheet event code and should be pasted into the worksheets's
code module (not a standard module and not the workbook's ThisWorkbook
module):

*******************************************
Right-click the worksheet's tab

Select 'View Code' from the menu and paste the code.

Alt-F11 to return to Excel.
*******************************************
 
H

henpat

Thanks

Norman Jones said:
Hi Henpat,

Try something like:

'=================>>
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim rng As Range

Set rng = Range("B4")
If Not Intersect(rng, Target) Is Nothing Then
'Do something, e.g.:
MsgBox "Hi!"
'or:
Call MyMacro
End If
End Sub
'<<================

This is worksheet event code and should be pasted into the worksheets's
code module (not a standard module and not the workbook's ThisWorkbook
module):

*******************************************
Right-click the worksheet's tab

Select 'View Code' from the menu and paste the code.

Alt-F11 to return to Excel.
*******************************************
 

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