Link to home
Start Free TrialLog in
Avatar of mato01
mato01Flag for United States of America

asked on

Change value in one cell based on value in another cell

I have a speadsheet where I need to change the value of the cell in Column C, based on the value of the cell in Column D.

Column C cells have a value of Medium.  I need to change that cell value to Medium Red if the value of the cell in Column D has a value that ends in 67.

I've attached a sample of the original file, and a sample of the desired results file.
DesiredSpreadsheet.xlsm
OriginalSpreadsheet.xlsm
Avatar of Saqib Husain
Saqib Husain
Flag of Pakistan image

Enter this formula in C2 and copy down

="MEDIUM"&IF(RIGHT(D2,2)="67"," RED","")
Avatar of mato01

ASKER

Can you convert this statement to vba.

Sometimes there could be more than MEDIUM in the cell, and this method would require me to handle the file.
ASKER CERTIFIED SOLUTION
Avatar of Saqib Husain
Saqib Husain
Flag of Pakistan image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mato01

ASKER

Had to change  a little, so that it was specific to MEDIUM, but works perfectly.  As always thanks a lot.

Sub red67()
    Dim cel As Range
    For Each cel In Range("C:C")
        If cel = "MEDIUM" Then
            If Right(cel.Offset(, 1), 2) = "67" Then
                If Right(cel, 4) <> "RED" Then
                    cel = cel & " RED"
                End If
            End If
        End If
    Next cel
End Sub