Results 1 to 5 of 5

Loop & Find problems

Threaded View

  1. #1
    Registered User
    Join Date
    05-10-2008
    Posts
    2

    Loop & Find problems

    I am trying to create a loop Macro that will search for the word "pediatric" in Column C of each Row, and when "pediatric" is found, enter "Peds" in Column E of that row.

    I created this macro using Record and then added a Loop function, but it is not working. I am getting a Loop Do syntax error when I "step into" the macro. As I'm sure will be obvious, I am very much a beginner with macros.

    Can anyone please tell me what mistakes I am making here?

    Thanks very much!

    Sub LoopPeds()
    '
    ' LoopPeds Macro
    ' Macro recorded 5/10/2008 by Mohom
    '
    ' Keyboard Shortcut: Ctrl+w
    
        x = 5
        
        Do While Cells(x, 3).Value <> ""
        Cells.Find(What:="Pediatric", After:=ActiveCell, LookIn:=xlFormulas, _
            LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
            MatchCase:=False, SearchFormat:=False).Activate
        Cells(x, 5).Select
        ActiveCell.FormulaR1C1 = "Peds"
        With ActiveCell.Characters(Start:=1, Length:=4).Font
            .Name = "Arial"
            .FontStyle = "Bold"
            .Size = 10
            .Strikethrough = False
            .Superscript = False
            .Subscript = False
            .OutlineFont = False
            .Shadow = False
            .Underline = xlUnderlineStyleNone
            .ColorIndex = xlAutomatic
                Cells(x, 6).Select
                x = x + 1
            Loop
       
    
        
    End Sub
    Last edited by royUK; 05-10-2008 at 10:44 AM.

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