Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Using Find and FindNext to Format Cell Text

Hi -
I know this is a simple question, but I'm looking for a way to find
all instances of a text in a single column - and format the first
found text color as black and all the remaining as white. I would
really appreciate a quick rundown on how to do this - thanks for all
you guys do.

Steve

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 396
Default Using Find and FindNext to Format Cell Text

Hi Steve

Here's the full code I wrote for you. Only 1 thing to change, see in the
code where.

Sub colouring()

Dim rngTextCells As Range
Dim lFirstRow As Long

With Columns("A") 'adjust to suit

On Error Resume Next
Set rngTextCells = .SpecialCells(xlCellTypeFormulas, 2)
lFirstRow = rngTextCells.Row
Set rngTextCells = Application.Union(rngTextCells,
..SpecialCells(xlCellTypeConstants, 2))
On Error GoTo 0

End With

If Not rngTextCells Is Nothing Then

rngTextCells.Font.ColorIndex = 2
lFirstRow = WorksheetFunction.Min(lFirstRow, rngTextCells.Row)
Cells(lFirstRow, rngTextCells.Column).Font.ColorIndex = 1

End If

End Sub


--
Wigi
http://www.wimgielis.be = Excel/VBA, soccer and music


" wrote:

Hi -
I know this is a simple question, but I'm looking for a way to find
all instances of a text in a single column - and format the first
found text color as black and all the remaining as white. I would
really appreciate a quick rundown on how to do this - thanks for all
you guys do.

Steve


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Using Find and FindNext to Format Cell Text

On Jul 16, 5:58 pm, Wigi wrote:
Hi Steve

Here's the full code I wrote for you. Only 1 thing to change, see in the
code where.

Sub colouring()

Dim rngTextCells As Range
Dim lFirstRow As Long

With Columns("A") 'adjust to suit

On Error Resume Next
Set rngTextCells = .SpecialCells(xlCellTypeFormulas, 2)
lFirstRow = rngTextCells.Row
Set rngTextCells = Application.Union(rngTextCells,
.SpecialCells(xlCellTypeConstants, 2))
On Error GoTo 0

End With

If Not rngTextCells Is Nothing Then

rngTextCells.Font.ColorIndex = 2
lFirstRow = WorksheetFunction.Min(lFirstRow, rngTextCells.Row)
Cells(lFirstRow, rngTextCells.Column).Font.ColorIndex = 1

End If

End Sub

--
Wigihttp://www.wimgielis.be= Excel/VBA, soccer and music

" wrote:
Hi -
I know this is a simple question, but I'm looking for a way tofind
all instances of a text in a single column - and format the first
found text color as black and all the remaining as white. I would
really appreciate a quick rundown on how to do this - thanks for all
you guys do.


Steve


Hey Wigi -
I implemented your code - and the correct column was A - it executed
successfully but nothing changed. I have multiple instances of the
same name in this column, and hypothetically the first one should have
been colored black, and all the rest white. Is this what the code was
meant to do? Thanks alot for your help.
Steve

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using Find & FindNext in a form BernzG[_13_] Excel Programming 3 August 19th 05 12:28 AM
Using 'Find' and 'FindNext' in vba SA3214 Excel Programming 3 March 25th 05 12:17 PM
Find, Findnext VBA Loop SMS - John Howard Excel Programming 5 November 13th 04 03:19 AM
Find...FindNext Problem mtsark Excel Programming 4 August 19th 04 04:09 PM


All times are GMT +1. The time now is 02:09 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"