View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
John[_19_] John[_19_] is offline
external usenet poster
 
Posts: 87
Default find by font size

I'm trying to use the find method instead of for/next loops because it's
supposed to be faster and is certainly a lot cleaner to use and see in
the program.

Thus:

Myrange = the range I want to look in

Set FoundIt = MyRange.Find(What:="" SearchOrder:=xlByColumns and so on
so it finds any cell with font.size = 18

And I'm done In two simple lines of code. If I want to look for more I
just use Findnext.

It looks like I should be able to do this but it doesn't work.

John



AndrewArmstrong wrote:
This should do what you want
-Andrew

Sub IdentifyFontSize18()

Dim Rng As Range
On Error Resume Next
Application.DisplayAlerts = False

'Have the user select a range to loop through
Set Rng = Application.InputBox(Prompt:="Please select a range
to run macro on.", _
Title:="SPECIFY RANGE", Type:=8)
On Error GoTo 0
Application.DisplayAlerts = True

'If the selection is blank, exit routine
If Rng Is Nothing Then
Exit Sub
Else

'Get the first row
Dim intrownum As Integer
intrownum = Rng.Row

'loop through each row
For Each c In Rng
If c.Font.Size = 18 Then
MsgBox "Cell " & Chr(c.Column + 64) & c.Row & " has
size 18 font"
End If
Next c

End If

End Sub