1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

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

Discussion in 'Business Applications' started by handball-cw, Jan 16, 2012.

Thread Status:
Not open for further replies.
Advertisement
  1. handball-cw

    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?
     
  2. Sponsor

  3. GeorgeJ

    GeorgeJ

    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
     
  4. handball-cw

    handball-cw Thread Starter

    Joined:
    Jan 16, 2012
    Messages:
    13
    have a1 content be replaced with the new content in b1;
     
  5. GeorgeJ

    GeorgeJ

    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.
     
  6. handball-cw

    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?
     
  7. handball-cw

    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?
     
  8. handball-cw

    handball-cw Thread Starter

    Joined:
    Jan 16, 2012
    Messages:
    13
    issue solved;
     
  9. Sponsor

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 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/1036526