LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Excel VBA Programming...How to Trigger an Event WhenYou Move Off a

Here is some selection change code. It calculates whenever the active cell is
moved.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Range("E2").Value = Range("C2").Value + Range("B2").Value
End Sub

Right click the sheet tab and select view code. Paste the code above... Not
you are going to loose you undo function with this code and it does not
recalc when delete is pressed (we can do this with on change code if you
wish)...

--
HTH...

Jim Thomlinson


" wrote:

Hello,

I've got what I think is a "simple problem" for Excel VBA, but can't
seem to get it working exactly the way I want. Here's a simple example
of what I'd like to do:

1) You have a Number in Cell: B2
2) You have another Number in Cell: C2
3) You calculate the result and put it in Cell: E2

I'd like to be able to enter numbers in Cells B2 and C2, and when I
"Move Off" either Cell B2 or C2, have the sum (ie: B2 + C2) calculated
and the result put in Cell E2. I'd like this to happen if I "Key Off"
(ie: up or down arrow) either B2 or C2, or "Mouse Click Off" (ie:
highlight Cell D4 and click on the mouse), or click on the "Delete Key"
on the Keyboard.

Is there an easy way to do this in VBA? The ActiveCell Property in
this case will give me B1 if I click on the "Up Arrow" after being on
B2, and B3 if I click on the "Down Arrow"... Since I don't know the
direction I've come from, I can't determine it was B2 in this
particular case...

Thanks a Bunch...


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
unable to get the excel app event trigger for for window resize [email protected] Excel Programming 0 November 30th 05 03:03 AM
trigger an EVENT when the value in a cell changes? Controls Freak Excel Programming 1 December 21st 04 07:24 AM
Excel VBA event trigger problem Milli[_2_] Excel Programming 4 April 26th 04 08:46 AM


All times are GMT +1. The time now is 05:33 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"