Can anybody help me out to write an excel macro that can change the color of a cell having a particular name. For eg in an excel sheet i want to change the color of all the cells to yellow that has the name "george" in it.
If you need to go thru a lot of cells, the find method will almost certainly be quicker:
With Worksheets("Sheet1".Range("a1:z500"
Set c = .Find("george", lookin:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
c.Interior.colorindex = 6
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address <> firstAddress
End If
End With
findStr = activesheet.cells(activecell.row,5).text
With Worksheets("Sheet2".columns("C"
Set c = .Find(findStr, lookin:=xlValues)
End With
If Not c Is Nothing Then
activecell.interior.colorindex = 6
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.