![]() |
Macros question
Hi all, I need some help editing code for my macro. I want to bold all line that have the word Total in them. There are 2 problems I'm runnin into: 1) I read the macro script - all cell addresses are hard codes . Ho can I have the script just go to the next line instead of a hard-code cell number. 2) How can I make the macro run over an over again until it reaches en of line? Thanks a ton -- cooldyoo ----------------------------------------------------------------------- cooldyood's Profile: http://www.excelforum.com/member.php...fo&userid=3561 View this thread: http://www.excelforum.com/showthread.php?threadid=55382 |
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 |
Macros question
It worked, thank you. I just have a quick question. I'd like to run th macro for the current sheet instead of hard-coding the sheet name. Wha do I need to change in this line? Set wks = Sheets("May 06") Thx again -- cooldyoo ----------------------------------------------------------------------- cooldyood's Profile: http://www.excelforum.com/member.php...fo&userid=3561 View this thread: http://www.excelforum.com/showthread.php?threadid=55382 |
Macros question
Can anyone tell me?? -- cooldyood ------------------------------------------------------------------------ cooldyood's Profile: http://www.excelforum.com/member.php...o&userid=35611 View this thread: http://www.excelforum.com/showthread...hreadid=553827 |
All times are GMT +1. The time now is 11:25 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com