ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Excel Test Formula (https://www.excelbanter.com/excel-programming/280903-excel-test-formula.html)

Lee

Excel Test Formula
 
I know this should be simple but I can't make it work.

If cell (A1) is greater cell (A2), place result in (A2)

Thank You

Lee

Don Guillett[_4_]

Excel Test Formula
 
I can only think of a worksheet change event.
right click on sheet tabview codeinsert thissave
will ONLY work for a change made in cell A2

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address < "$A$2" Then Exit Sub
If Target.Offset(-1) Target Then Target.Offset (-1)
End Sub

"Lee" wrote in message
...
I know this should be simple but I can't make it work.

If cell (A1) is greater cell (A2), place result in (A2)

Thank You

Lee




Tom Ogilvy

Excel Test Formula
 
This would require a circular formula in A2. This usually causes an error
(although you can allow it). I would suggest using a macro

Private Sub Worksheets_Calculate()
If range("A1").Value Range("A2").Value then
range("A2").Value = Range("A1").Value
End if
End Sub

Right click on the sheet tab and select view code. Paste in/write code
similar to the above.

--
Regards,
Tom Ogilvy

"Lee" wrote in message
...
I know this should be simple but I can't make it work.

If cell (A1) is greater cell (A2), place result in (A2)

Thank You

Lee




Don Guillett[_4_]

Excel Test Formula
 
If Target.Offset(-1) Target Then Target.Offset (-1)

correct to
If Target.Offset(-1) Target Then target=Target.Offset (-1)

"Don Guillett" wrote in message
...
I can only think of a worksheet change event.
right click on sheet tabview codeinsert thissave
will ONLY work for a change made in cell A2

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address < "$A$2" Then Exit Sub
If Target.Offset(-1) Target Then Target.Offset (-1)
End Sub

"Lee" wrote in message
...
I know this should be simple but I can't make it work.

If cell (A1) is greater cell (A2), place result in (A2)

Thank You

Lee







All times are GMT +1. The time now is 11:18 PM.

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