Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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

  #2   Report Post  
Posted to microsoft.public.excel.programming
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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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

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
macros vba question [email protected] Excel Worksheet Functions 1 December 4th 09 05:56 AM
Question on Macros Juan Carlos Excel Discussion (Misc queries) 2 September 10th 09 03:56 PM
Question about macros. [email protected] Excel Discussion (Misc queries) 3 May 11th 06 09:01 PM
question macros wnl2007 Excel Worksheet Functions 1 June 10th 05 10:56 PM
A question regarding Macros DangerMouse114[_8_] Excel Programming 3 May 31st 04 07:11 PM


All times are GMT +1. The time now is 12:35 AM.

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"