FrenchCelt
Board Regular
- Joined
- May 22, 2018
- Messages
- 214
- Office Version
- 365
- Platform
- Windows
Hello,
I'm trying to loop a sequence of code until all instances of specific text in my sheet have been modified a certain way.
This is what I tried on my own:
I had hoped that by simply repeating the code 10 times (it will never appear more often than 10 times, hence why I picked that number), it could find all instances of NO PINWHEEL and modify as instructed, but it only works sporadically and sometimes catches them all and sometimes not, depending on placement within the sheet. Can anyone suggest a better solution?
I'm trying to loop a sequence of code until all instances of specific text in my sheet have been modified a certain way.
This is what I tried on my own:
VBA Code:
For x = 1 To 10
Cells.Find(What:="NO PINWHEEL", After:=ActiveCell, LookIn:=xlValues, _
LookAt:=xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
Range(ActiveCell.Offset(0, 0), ActiveCell.Offset(-1, 0)).Select
With Selection.Font
.Name = "Andale WT"
.Size = 8
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
.TintAndShade = 0
.ThemeFont = xlThemeFontNone
End With
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Cells.Find(What:="NO PINWHEEL", After:=ActiveCell, LookIn:=xlValues, _
LookAt:=xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).EntireColumn.AutoFit
Next x
I had hoped that by simply repeating the code 10 times (it will never appear more often than 10 times, hence why I picked that number), it could find all instances of NO PINWHEEL and modify as instructed, but it only works sporadically and sometimes catches them all and sometimes not, depending on placement within the sheet. Can anyone suggest a better solution?