Hello Excel Forum--this is my first post on this site although I've used this site many times. I need a code that can find a specific value in a specific column and once that value is found, look at another column in the same row for a specific value. If both values are found, update the first value found with a specific value. For example;
I have data filled in all cells range (A1:C100). Look in Column A for the value "Apples", Say "Apples" is the value of cell A13. Then look at C13 to see if it has the value of "005". If it does not, then do nothing. If it does, then update cell A13 with the value "Apples 005". Then continue the process through the end of Column A.
Here is the code I have tried to work with:
Sub Test()
Set target = Sheets("Sheet1").Range("A:A")
Set target1 = Sheets("Sheet1").Range("C:C")
For Each cell In target1
If cell.Value = "005"
Then
For Each cell In target
If cell.Value = "Apples"
cell.Value = "Apples 005"
End If
Next cell
End Sub
I know how to make this code work for one condition but not for two conditions. I have similar restriction issues with the following code:
Sub Test1()
If Range("A13").Value = "Apples" And Range("C13").Value = "005" Then
Range("A13").Value = "Apples 005"
End If
End Sub
This is good if I always knew the location of the value of "Apples", but I do not. I only know the Column and value. Any help on this will be much appreciated, as I search this site for similar issues but have not found any. Also, I can make this work via a formula but I prefer a to stick with a VBA macro.
Thank you!
Bookmarks