PDA

View Full Version : Solved: LOOK CELL IN COLUMN THEN HIGHLIGHT



Nicolaf
11-02-2011, 05:00 AM
Hi,

I would like to look for a specific date in Sheet1 column B then once found highlight in bold the cells next to it in column D and E.

So if specific date is in Sheet1 Cell B10 I would like macro to highlight in bold Cells D10 and E10.

Specific date to look for is found in Sheet2 Cell A13.

Thanks,
Nix :think:

mancubus
11-02-2011, 07:32 AM
hi.
try the code with a copy o f your file.


Sub FindSpecDateFormat()

Dim ws1 As Worksheet, ws2 As Worksheet
Dim foundCell As Range
Dim srcDate As Date
Dim firstAddress As String

Set ws1 = Worksheets("Sheet1")
Set ws2 = Worksheets("Sheet2")
srcDate = ws2.Range("A13").Value

With ws1.Columns(2)
'http://msdn.microsoft.com/en-us/library/aa195732(v=office.11).aspx
On Error Resume Next
Set foundCell = .Find(srcDate, LookIn:=xlFormulas)
On Error GoTo 0
If Not foundCell Is Nothing Then
firstAddress = foundCell.Address
Do
foundCell.Offset(0, 2).Resize(1, 2).Font.Bold = True
Set foundCell = .FindNext(foundCell)
Loop While Not foundCell Is Nothing And foundCell.Address <> firstAddress
End If
End With

End Sub

Nicolaf
11-04-2011, 07:47 AM
Great thanks!


:hi:

mancubus
11-04-2011, 08:26 AM
you're wellcome.