Solved

Change value in one cell based on value in another cell

Posted on 2012-03-17
4
176 Views
Last Modified: 2012-08-14
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
0
Comment
Question by:mato01
  • 2
  • 2
4 Comments
 
LVL 43

Expert Comment

by:Saqib Husain, Syed
ID: 37734051
Enter this formula in C2 and copy down

="MEDIUM"&IF(RIGHT(D2,2)="67"," RED","")
0
 

Author Comment

by:mato01
ID: 37734063
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.
0
 
LVL 43

Accepted Solution

by:
Saqib Husain, Syed earned 200 total points
ID: 37734075
Sub red67()
    Dim cel As Range
    For Each cel In Range("C:C")
        If Right(cel.Offset(, 1), 2) = "67" Then
            If Right(cel, 4) <> " RED" Then
                cel = cel & " RED"
            End If
        End If
    Next cel
End Sub
0
 

Author Closing Comment

by:mato01
ID: 37734109
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
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Drop Down List with Unique/Distinct Values (enhancing the Combo-Box with a few steps and a little code) David miller (dlmille) Intro Have you ever created a data validation list from a database field or spreadsheet column (e.g., Zip Codes or Co…
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now