ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Comparing the active cell value against another value in the row (https://www.excelbanter.com/excel-discussion-misc-queries/92466-comparing-active-cell-value-against-another-value-row.html)

Clayton

Comparing the active cell value against another value in the row
 
I have two values in a row, I want to click on the active cell and have it
display a calculation based on the value in the active cell versus a fixed
cell in the same row. I have tried to use the msgbox function but can't seem
to make it work. The values are consist of a customer discount off list
versus a dealer discount off list. I need to calculate the margin based on
these two values. The formula is 1-((1-dealer discount)/(1-customer
discount)). Can this be done in Visual basic?

mrice

Comparing the active cell value against another value in the row
 

I would suggest a simple macro based upon the Worksheet_SelectionChange
event

Something like

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target = "" Then Exit Sub
MsgBox Target - Range("A1")
End Sub

for a simple subtraction which you can amend for your specific formula.


--
mrice

Research Scientist with many years of spreadsheet development experience
------------------------------------------------------------------------
mrice's Profile: http://www.excelforum.com/member.php...o&userid=10931
View this thread: http://www.excelforum.com/showthread...hreadid=549171



All times are GMT +1. The time now is 08:39 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com