Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 78
Default Insert Formula based in cell user clicks

In need to insert a simple formula into Column J based on the cell in the
same row which is clicked by the user. Only one of the cells will be clicked
and color changed between the following cells F,H,L,M or N. The formula is
the product of 3 cells, 2 of which are fixed and the last one should become
whichever cell the user clicks.

e.g.

Cells(j, "J") = Cells(j, "E") * Cells(j, "I") * clicked cell(either cell F,
H, L, M or N)


Is this possible to do?


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Insert Formula based in cell user clicks

You could use a worksheet_selectionchange event. But that would fire each time
you changed the selection -- either by mouse or by arrow keys or by scrolling.
(There is no event for clicking on a cell.)

So how about using the _beforerightclick event instead?

If you want to try, rightclick on the worksheet tab that should have this
behavior. Select View code and paste this into the code window that opened up
(usually on the right hand side).

Option Explicit
Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean)

Dim res As Double

With Target
If .Cells.Count 1 Then
Exit Sub
End If

If Intersect(.Cells, Me.Range("F:F,H:H,L:N")) Is Nothing Then
Exit Sub
End If

Cancel = True 'stop popup menu from showing up

On Error Resume Next
res = Me.Cells(.Row, "E").Value _
* Me.Cells(.Row, "I").Value _
* .Value
If Err.Number < 0 Then
Err.Clear
MsgBox "Failed--check for numbers!"
Else
Me.Cells(.Row, "J").Value = res
End If
End With

End Sub

aileen wrote:

In need to insert a simple formula into Column J based on the cell in the
same row which is clicked by the user. Only one of the cells will be clicked
and color changed between the following cells F,H,L,M or N. The formula is
the product of 3 cells, 2 of which are fixed and the last one should become
whichever cell the user clicks.

e.g.

Cells(j, "J") = Cells(j, "E") * Cells(j, "I") * clicked cell(either cell F,
H, L, M or N)

Is this possible to do?


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 78
Default Insert Formula based in cell user clicks

I was able to get this working so no need to post a reply. Thanks.

"aileen" wrote:

In need to insert a simple formula into Column J based on the cell in the
same row which is clicked by the user. Only one of the cells will be clicked
and color changed between the following cells F,H,L,M or N. The formula is
the product of 3 cells, 2 of which are fixed and the last one should become
whichever cell the user clicks.

e.g.

Cells(j, "J") = Cells(j, "E") * Cells(j, "I") * clicked cell(either cell F,
H, L, M or N)


Is this possible to do?


Reply
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
confirmation window once user clicks submit on user from sam Excel Programming 4 July 7th 09 06:02 PM
Pause While User Clicks on Chart Series JayWes Excel Programming 3 June 19th 07 02:55 PM
How to have errr msg pop up when user clicks on locked cell perfection Excel Discussion (Misc queries) 4 May 29th 07 06:27 AM
creating popup menu when user right-clicks on cell [email protected] Excel Programming 0 April 10th 07 07:58 PM
Counter for user clicks Anthony Excel Programming 5 March 5th 07 01:51 PM


All times are GMT +1. The time now is 11:42 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"