Hello Paul and 1976,
I incorporated both of your suggestions into my updated code and can now select and apply the new color to the current row in the loop. However, the procedure aborts prematurely with no error and does not continue down to the next cell in the "For Each Loop".
Here is my newest code:
Public Sub UpdateTargetData(X As String, Y As String)
Dim Cell As Range
Dim SelectedRange As Range
Dim CellAddress As String
For Each Cell In Range("GeneratedColorCodes")
If Cell.Value = Y Then
Cell.Value = X
CellAddress = Cell.Address
Range(CellAddress, Cells(Cell.Row, 1)).Select
Set SelectedRange = Selection
'Perform some formatting
SelectedRange.Interior.Color = hexa_color(Cell.Value)
Range(CellAddress).Select
End If
Next Cell
End Sub
Here is what the worksheet looks like after the first iteration of the loop:
Capture2.JPG
Just so my desired result is a little more clear, the application allows the users to change colors that they have already applied to the database. In my trouble-shooting step, The orange color in A46 has been changed to Blue. When the user clicks the button "Update Color Codes", my code creates the Hexadecimal color code for newly applied blue in B46. The previously applied color code for the orange is in F46
The code then finds all occurrences of #F4B084 (cells in orange) in a range I named "GeneratedColorCodes which is the column you see labeled "Cell Color" containing all the Hex codes for each row.
Notice that the first cell in the loop was found, changed to the new hex code for blue and the row was formatted blue but the loop aborted without continuing the loop.
Any ideas? Thanks.