filling 2 cells with color based on one cells info?

Ruff0r

New Member
Joined
May 12, 2008
Messages
5
If cell a1 has a value of XX (XX will be filled with text, not numbers) is there a way to have excel search that row (b1 through bc1) for XX and fill that cell with yellow and the cell directly to the right with yellow.

I already use a Cell.Interior.ColorIndex and CountByColor to add up the cells that are filled yellow.

Thank You, please let me know if you need more information.
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Look at this

Excel Workbook
ABCDEF
1Test
2
3AnotherTestColour
4Not todayTestColour
5Where ElseTestColour
Sheet2

Using this to colour

<font face=Courier New><SPAN style="color:#00007F">Sub</SPAN> findText()<br><SPAN style="color:#00007F">Dim</SPAN> cell <SPAN style="color:#00007F">As</SPAN> Range<br><SPAN style="color:#00007F">For</SPAN> <SPAN style="color:#00007F">Each</SPAN> cell <SPAN style="color:#00007F">In</SPAN> Range("A3:F5")<br>    <SPAN style="color:#00007F">If</SPAN> cell.Value = Range("A1") <SPAN style="color:#00007F">Then</SPAN><br>        cell.Interior.Color = vbYellow<br>        cell.Offset(0, 1).Interior.Color = vbYellow<br>    <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">If</SPAN><br>    <br><SPAN style="color:#00007F">Next</SPAN> cell<br><br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>
 
Upvote 0
Your reply makes complete sense but for some reason it is not working. Below is the exact range and cells that I am trying to use this code with. Also I forgot to mention I need the same concept for range a3:ba3 - a17:ba17. Any help would be greatly appreciated!

Sub findText()
Dim cell As Range
For Each cell In Range("A2:BA2")
If cell.Value = Range("BF2") Then
cell.Interior.Color = vbYellow
cell.Offset(0, 1).Interior.Color = vbYellow
End If

Next cell

End Sub
 
Upvote 0
Have you any conditional formatting

Sub findText()
Dim cell As Range
For Each cell In Range("A2:BA2,a3:ba3,a17:ba17")
If cell.Value = Range("BF2") Then
cell.Interior.Color = vbYellow
cell.Offset(0, 1).Interior.Color = vbYellow
End If
Next cell
End Sub
 
Upvote 0
Thank You very much, I got everything to work, I do not have any conditional Formatting I just forgot to run the macro.
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,282
Members
452,902
Latest member
Knuddeluff

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top