BulldogMike
asked on
Excel loop(?) coding to find and update all entries
How do I approach the following problem. I used the record macro function to create the following code to bold and color the Months in a spreadsheet. How can I modify it to "loop"(?) through the spreadsheet to find and update all the entries?
Thanks
Cells.Find(What:="January" , After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activ ate
ActiveCell.Replace What:="January", Replacement:="January", LookAt:= _
xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=True
Cells.FindNext(After:=Acti veCell).Ac tivate
Cells.Find(What:="February ", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activ ate
ActiveCell.Replace What:="February", Replacement:="February", LookAt:= _
xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=True
Cells.FindNext(After:=Acti veCell).Ac tivate
etc....................... ...
Thanks
Cells.Find(What:="January"
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activ
ActiveCell.Replace What:="January", Replacement:="January", LookAt:= _
xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=True
Cells.FindNext(After:=Acti
Cells.Find(What:="February
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activ
ActiveCell.Replace What:="February", Replacement:="February", LookAt:= _
xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=True
Cells.FindNext(After:=Acti
etc.......................
It would help a LOT if you attached the spreadsheet, if possible.
That code should do it, assuming you like red.
THomas
THomas
Sub BoldMonths()
Dim i As Long, rg As Range, j As Long, strMonth As String, lgCount As Long
Application.ScreenUpdating = False
Set rg = [a1]
For i = 1 To 12
strMonth = Format(DateValue(i & "/1/2010"), "mmmm")
j = WorksheetFunction.CountIf(ActiveSheet.UsedRange, "*" & strMonth & "*")
For lgCount = 1 To j
Set rg = Cells.Find(What:=strMonth, After:=rg, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)
rg.Font.Bold = True
rg.Interior.ColorIndex = 3
Next lgCount
Set rg = [a1]
Err.Clear
Next i
Application.ScreenUpdating = True
End Sub
ASKER
ASKER
Thomas
It would be helpful to me if you could comment your code so I can figure out what its doing. I'm not a professionally trained programmer so sometimes need a little more help to understand.
Thank You
Mike
It would be helpful to me if you could comment your code so I can figure out what its doing. I'm not a professionally trained programmer so sometimes need a little more help to understand.
Thank You
Mike
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thomas
Thanks for you help and advice - I'll be watching you. I also am a trained professional, a pharmacist. Your knowledge level is impressive.
Thanks Again
Mike
Thanks for you help and advice - I'll be watching you. I also am a trained professional, a pharmacist. Your knowledge level is impressive.
Thanks Again
Mike
ASKER
Very knowledgeable and helpful
Glad to help Mike. Thanks for the grade,
Thomas
Thomas