Thread: Macros question
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Jim Thomlinson Jim Thomlinson is offline
external usenet poster
 
Posts: 5,939
Default Macros question

Here is some code. To make it more efficient it uses find instead of
searching each cell one at a time... You will need to change some things to
suit.

Public Sub boldRows()
Dim rngFound As Range
Dim rngToSearch As Range
Dim rngFoundAll As Range
Dim wks As Worksheet
Dim strFirst As String

Set wks = Sheets("Sheet3") 'Change thins
Set rngToSearch = wks.Range("A:A") 'Change This
Set rngFound = rngToSearch.Find(What:="Total", _
LookIn:=xlFormulas, _
LookAt:=xlPart, _
MatchCase:=False)
If rngFound Is Nothing Then
MsgBox "Couldn't Find Total"
Else
strFirst = rngFound.Address
Set rngFoundAll = rngFound
Do
Set rngFoundAll = Union(rngFound, rngFoundAll)
Set rngFound = rngToSearch.FindNext(rngFound)
Loop Until rngFound.Address = strFirst
rngFoundAll.EntireRow.Font.Bold = True
End If
End Sub

--
HTH...

Jim Thomlinson


"cooldyood" wrote:


Hi all,

I need some help editing code for my macro. I want to bold all lines
that have the word Total in them. There are 2 problems I'm running
into:

1) I read the macro script - all cell addresses are hard codes . How
can I have the script just go to the next line instead of a hard-coded
cell number.

2) How can I make the macro run over an over again until it reaches end
of line?

Thanks a ton!


--
cooldyood
------------------------------------------------------------------------
cooldyood's Profile: http://www.excelforum.com/member.php...o&userid=35611
View this thread: http://www.excelforum.com/showthread...hreadid=553827