+ Reply to Thread
Results 1 to 3 of 3

Macro - Loop or Next

Hybrid View

Guest Macro - Loop or Next 04-02-2006, 01:50 AM
Guest Re: Macro - Loop or Next 04-02-2006, 02:10 AM
Guest Re: Macro - Loop or Next 04-03-2006, 05:25 PM
  1. #1
    Rashid
    Guest

    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. #2
    Norman Jones
    Guest

    Re: 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" <syedjameel@sympatico.ca> wrote in message
    news:ViJXf.4617$u15.644751@news20.bellglobal.com...
    >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. #3
    Gerencsér Gábor
    Guest

    Re: 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" <syedjameel@sympatico.ca> az alábbiakat írta a következõ
    hírüzenetben: ViJXf.4617$u15.644751@news20.bellglobal.com...
    >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 to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1