PC Review


Reply
Thread Tools Rate Thread

Calculation of cell value with worksheet change event

 
 
Raj
Guest
Posts: n/a
 
      30th May 2008
Hi,

I have an integer in cell a1. When an integer is input in cell b1, I
need the value in cell a1 multiplied by the value in cell b1 and the
result placed in cell a1. To achieve this I am using the
Worksheet_change event with target range as b1. The program works ok
when the user inputs the value in cell b1 and then presses the Enter
key. However, if the user clicks outside cell b1 after inputting the
value in cell b1, then the value in cell a1 does not change. How do I
ensure that the calculation takes place when the user exits b1?

How can I achieve this through a worksheet event?. Is there an event
that fires when the cell is exited?
Is there any other way to do this?

Thanks in advance for the help.

Regards,
Raj
 
Reply With Quote
 
 
 
 
aidan.heritage@virgin.net
Guest
Posts: n/a
 
      30th May 2008
On May 30, 5:03*pm, Raj <rsp...@gmail.com> wrote:
> Hi,
>
> I have an integer in cell a1. When an integer is input in cell b1, I
> need the value in cell a1 multiplied by the value in cell b1 and the
> result placed in cell a1. To achieve this I am using the
> Worksheet_change event with target range as b1. The program works ok
> when the user inputs the value in cell b1 and then presses the Enter
> key. However, if the user clicks outside cell b1 after inputting the
> value in cell b1, then the *value in cell a1 does not change. How do I
> ensure that the calculation takes place when the user exits b1?
>
> How can I achieve this through a worksheet event?. Is there an event
> that fires when the cell is exited?
> Is there any other way to do this?
>
> Thanks in advance for the help.
>
> Regards,
> Raj


Use the selection change event instead - this returns as a target the
cell that has just been left
 
Reply With Quote
 
Gary''s Student
Guest
Posts: n/a
 
      30th May 2008
Private Sub Worksheet_Change(ByVal Target As Range)
Set b1 = Range("B1")
If Intersect(Target, b1) Is Nothing Then Exit Sub
Application.EnableEvents = False
'
' update A1
'
Application.EnableEvents = True
MsgBox ("B1 changed")
End Sub

Should work if B1 is refreshed with a value followed by ENTER, or by a
mouseclick, or by an ARROW movement.
--
Gary''s Student - gsnu200789


"Raj" wrote:

> Hi,
>
> I have an integer in cell a1. When an integer is input in cell b1, I
> need the value in cell a1 multiplied by the value in cell b1 and the
> result placed in cell a1. To achieve this I am using the
> Worksheet_change event with target range as b1. The program works ok
> when the user inputs the value in cell b1 and then presses the Enter
> key. However, if the user clicks outside cell b1 after inputting the
> value in cell b1, then the value in cell a1 does not change. How do I
> ensure that the calculation takes place when the user exits b1?
>
> How can I achieve this through a worksheet event?. Is there an event
> that fires when the cell is exited?
> Is there any other way to do this?
>
> Thanks in advance for the help.
>
> Regards,
> Raj
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cell Change triggers Worksheet Event Charles Microsoft Excel Programming 13 9th Jan 2010 12:13 AM
worksheet change event only if cell was blank Sliman Microsoft Excel Programming 4 22nd Jun 2008 10:45 PM
change event on specific cell rather than worksheet =?Utf-8?B?ZnJlbmRhYnJlbmRhMQ==?= Microsoft Excel Misc 10 21st Sep 2006 03:37 AM
Cell value change to trigger macro (worksheet change event?) =?Utf-8?B?TmVpbCBHb2xkd2Fzc2Vy?= Microsoft Excel Programming 4 10th Jan 2006 01:55 PM
Change Cell from Validated List Not Firing Worksheet Change Event marston.gould@alaskaair.com Microsoft Excel Programming 3 4th Oct 2004 03:00 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:58 AM.