PDA

View Full Version : Find Values in Different Columns and Figure out where to place the values



trevor2524
09-03-2014, 12:59 PM
I'm trying to figure out the next portion of this big macro I have.


Sub colorValueCheck()
Dim sOne As Worksheet
Dim sTwo As Worksheet
Set sOne = ThisWorkbook.Sheets("Sheet1") ' CHANGE ME
Set sTwo = ThisWorkbook.Sheets("Sheet2") ' CHANGE ME
Dim startRow1 As Integer
Dim endRow1 As Long
startRow1 = 2
endRow1 = sOne.Cells(Rows.Count, "C").End(xlUp).Row
Dim startRow2 As Integer
Dim endRow2 As Long
startRow2 = 2
endRow2 = sTwo.Cells(Rows.Count, "A").End(xlUp).Row
For x = startRow1 To endRow1 Step 1
If sOne.Cells(x, 3).Interior.ColorIndex <> -4142 Then
For y = startRow2 To endRow2 Step 1
If sOne.Cells(x, 3).Value = sTwo.Cells(y, 1) Then
If sTwo.Cells(y, 9).Value <> "Yes" Then
If sOne.Cells(x, 6) = sTwo.Cells(y, 4) Then
sTwo.Cells(y, 8) = "Yes"
End If
End If
End If
Next y
End If
Next x
End Sub
The next portion is

If the Value of Column I = "Yes" then the program will check the row right below it and see if that Column has a value of "Yes" if it does not it will check to see if there is a Value in Column D in that corresponding row. If there is it will proceed onto the Steps created above. If it doesn't then it will retrieve the value Found in Column F from Sheet1 that corresponds to this color value. It can do this a total of 3 times.