ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Findind values in a worksheet and fornatting them (https://www.excelbanter.com/excel-programming/335797-findind-values-worksheet-fornatting-them.html)

chrisrowe_cr[_2_]

Findind values in a worksheet and fornatting them
 

Hi all,

I need a bit of VB code to run off of a button which when clicked wil
check a list of values (say in the range J2:J30) and format any othe
cells on the worksheet to say bold blue text and italic that match th
range mentioned before.

Can anyone help with this

--
chrisrowe_c
-----------------------------------------------------------------------
chrisrowe_cr's Profile: http://www.excelforum.com/member.php...fo&userid=2522
View this thread: http://www.excelforum.com/showthread.php?threadid=39099


Tom Ogilvy

Findind values in a worksheet and fornatting them
 
Look at the sample code provided with the FindNext method of the range
object (in Excel VBA help). It should be easily adaptable to your
requirement.

--
Regards,
Tom Ogilvy

"chrisrowe_cr"
wrote in message
news:chrisrowe_cr.1sw0en_1122566780.8384@excelforu m-nospam.com...

Hi all,

I need a bit of VB code to run off of a button which when clicked will
check a list of values (say in the range J2:J30) and format any other
cells on the worksheet to say bold blue text and italic that match the
range mentioned before.

Can anyone help with this?


--
chrisrowe_cr
------------------------------------------------------------------------
chrisrowe_cr's Profile:

http://www.excelforum.com/member.php...o&userid=25220
View this thread: http://www.excelforum.com/showthread...hreadid=390996




bhofsetz[_119_]

Findind values in a worksheet and fornatting them
 

Here is a modified version of the find next code Tom is referring to.
Give it a try


Code
-------------------
Sub FormatFoundValues()
Dim entry As Range, foundentry As Range, firstaddress As String
For Each entry In Range("J2:J30")
Set foundentry = Cells.find(what:=entry.Value)
If Not foundentry Is Nothing Then
firstaddress = foundentry.Address
Do
With foundentry.Font
.ColorIndex = 5
.Bold = True
.Italic = True
End With
Set foundentry = Cells.FindNext(After:=foundentry)
Loop While Not foundentry Is Nothing And foundentry.Address < firstaddress
End If
Next entry
End Su
-------------------


HT

--
bhofset
-----------------------------------------------------------------------
bhofsetz's Profile: http://www.excelforum.com/member.php...fo&userid=1880
View this thread: http://www.excelforum.com/showthread.php?threadid=39099



All times are GMT +1. The time now is 08:25 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com