Solved: excel-replace content of cell-1 if cell-2 is > cell-1

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

handball-cw

Thread Starter
Joined
Jan 16, 2012
Messages
13
hi, i have 2-excel cells in the same sheet, both contain manually entered numbers; cell-2 changes frequently; if the existing entry in cell-1 is < than the new entry in cell-2, cell-1 should immediately reflect this new value. how do you create this formula?
 
Joined
Jan 16, 2012
Messages
144
A little confused here

2 cells with manuall entered data (say A1 and B1)
B1 changes frequently
if A1 < B1
what do you want to happen to A1?

Do you mean using the conditional formatting? (turn the cell red?)
=A1<B1
 
Joined
Jan 16, 2012
Messages
144
Right click the sheet tab and view code

Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Range("A1").Value < Range("B1").Value Then
        Range("A1").Value = Range("B1").Value
    End If
End Sub
No matter what is changed on the sheet, A1 will either be greater than or equel to B1.
 

handball-cw

Thread Starter
Joined
Jan 16, 2012
Messages
13
Hi, thanks for your input; i have a 'workbook' with over 20 'worksheets' with each work sheet in the same format (same rows/cells...different data)...each 'worksheet' needs this done; I am not familiary with 'private sub worksheets'...is there a way to implement this routine in each worksheet with minimal work?
 

handball-cw

Thread Starter
Joined
Jan 16, 2012
Messages
13
hi, i googled this and found the answer; however, i decscribed 1/2 of the origional problem; the 2nd half is a 2nd set of cells need a similar calculation; i copied the above example (after successfully implemented on the 1st set of cells), into the 'view code' window, then added a suffix of '1' to the 'Worksheet_SelectionChange' so it now appears as "Worksheet_SelectionChange1"...however, this routine did not execute; what else needs to be done?
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Staff online

Top