Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Macro - Loop or Next

I am a new to Excel VBA and trying write a macro for find a specific word in
a range. If the specific word is found change the colour.

My problem is how to get a loop going ?? here is my code PLEASE HELP

Sub colour()
Application.ScreenUpdating = False
Range("A:A").Select

Selection.find(What:="summary", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, _
MatchCase:=False).Activate
ActiveCell.Select
ActiveCell.Font.Bold = True
ActiveCell.Font.ColorIndex = 3

Next

End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Macro - Loop or Next

Hi Rashid,

From VBA help:
'==============================
Find Method Example

This example finds all cells in the range A1:A500 on worksheet one that
contain the value 2, and then it makes those cells gray.

With Worksheets(1).Range("a1:a500")
Set c = .Find(2, lookin:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
c.Interior.Pattern = xlPatternGray50
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address < firstAddress
End If
End With
'==============================


---
Regards,
Norman



"Rashid" wrote in message
.. .
I am a new to Excel VBA and trying write a macro for find a specific word
in a range. If the specific word is found change the colour.

My problem is how to get a loop going ?? here is my code PLEASE HELP

Sub colour()
Application.ScreenUpdating = False
Range("A:A").Select

Selection.find(What:="summary", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext,
_
MatchCase:=False).Activate
ActiveCell.Select
ActiveCell.Font.Bold = True
ActiveCell.Font.ColorIndex = 3

Next

End Sub




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default Macro - Loop or Next

Sub MyMarker()
Dim os
Dim MyString As String
MyString = InputBox("Search for this: ", "MyMarker")
Cells.Find(What:=MyString, After:=ActiveCell, LookIn:=xlFormulas,
LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:=False) _
.Activate
Selection.Font.ColorIndex = 3
os = ActiveCell.Address
Cells.FindNext(After:=ActiveCell).Activate
Selection.Font.ColorIndex = 3

Do Until ActiveCell.Address = os
Cells.FindNext(After:=ActiveCell).Activate
Selection.Font.ColorIndex = 3
Loop
End Sub

Cheers, Gabor

"Rashid" az alábbiakat írta a következő
hírüzenetben: ...
I am a new to Excel VBA and trying write a macro for find a specific word
in a range. If the specific word is found change the colour.

My problem is how to get a loop going ?? here is my code PLEASE HELP

Sub colour()
Application.ScreenUpdating = False
Range("A:A").Select

Selection.find(What:="summary", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext,
_
MatchCase:=False).Activate
ActiveCell.Select
ActiveCell.Font.Bold = True
ActiveCell.Font.ColorIndex = 3

Next

End Sub




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
Help with using a Macro Loop Mark Costello[_2_] Excel Discussion (Misc queries) 5 October 19th 07 02:01 PM
Loop to run macro each row PST Excel Discussion (Misc queries) 1 May 17th 07 06:36 AM
how to put a loop in a macro? Khoshravan New Users to Excel 4 May 14th 06 01:22 PM
Loop Macro? Carmen Excel Programming 3 May 10th 05 01:00 PM


All times are GMT +1. The time now is 05:52 AM.

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

About Us

"It's about Microsoft Excel"