Excel Test Formula

L

Lee

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
 
D

Don Guillett

I can only think of a worksheet change event.
right click on sheet tab>view code>insert this>save
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
 
T

Tom Ogilvy

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.
 
D

Don Guillett

If Target.Offset(-1) > Target Then Target.Offset (-1)

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top