?
Solved

Change value in one cell based on value in another cell

Posted on 2012-03-17
4
Medium Priority
?
183 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 800 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …

762 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