Full Version: Simple Highlighting code
UtterAccess Discussion Forums > Microsoft® Office > Microsoft Excel
spinner
Hello everyone,

I would like to have in my macro when it looks in a certain range (E4:E20) it would check for a value (10000000). If it found this value it would then highlight that entire row. I don't know much about VBA, so I hope it's something simple

Thanks in adavance
WillR
Try this code... you need to amend the sheet reference to your sheet

CODE
Sub FindGetInput()
Dim myVal As Variant
Dim fCell As Range
Dim R As Range
Set R = Worksheets("Sheet1").Range("E4:E20")
myVal = InputBox("Enter Value To Find")
Set fCell = R.Find(What:=myVal, _
After:=R.Cells(R.Cells.Count), _
        LookIn:=xlValues, LookAt:=xlPart, _
        SearchOrder:=xlByRows, SearchDirection:=xlNext, _
        MatchCase:=False)
If fCell Is Nothing Then
MsgBox "Can't find your value"
Exit Sub
End If
fCell.EntireRow.Interior.ColorIndex = 6
End Sub


HTH
spinner
Thanks,

This will work fine smile.gif
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.