Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
.find help
I have the following code that works fine. What I would like to know, is
there a way to write the For each wks....Next wks statement to set more than one font attribute at a time? My code finds the cell then only sets the font name. Can I set the font bold and italic at the same time? How can I code this different to make it work the way I want? Thank you. Private Sub Testing() Dim wks As Worksheet For Each wks In ActiveWorkbook.Worksheets On Error GoTo quit wks.Cells.Find(What:="test", After:=ActiveCell, LookIn:=xlFormulas, _ LookAt:=xlWhole, SearchOrder:=xlByColumns, _ SearchDirection:=xlNext, MatchCase:=False).Font.Name = "Times New Roman" Next wks quit: Exit Sub End Sub |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
.find help
Hi C,
See VBA help on the Find method. Adapting the given example to your requirements, try: '============ Sub Tester01() Dim wks As Worksheet Dim c As Range Dim firstAddress As String Const sStr As String = "test" '<<==== CHANGE For Each wks In ActiveWorkbook.Worksheets With wks.Cells Set c = .Find(sStr, LookIn:=xlValues) If Not c Is Nothing Then firstAddress = c.Address Do With c.Font .Bold = True .Italic = True End With Set c = .FindNext(c) Loop While Not c Is Nothing _ And c.Address < firstAddress End If End With Next wks End Sub '<<============ --- Regards, Norman "Wylie C" wrote in message ... I have the following code that works fine. What I would like to know, is there a way to write the For each wks....Next wks statement to set more than one font attribute at a time? My code finds the cell then only sets the font name. Can I set the font bold and italic at the same time? How can I code this different to make it work the way I want? Thank you. Private Sub Testing() Dim wks As Worksheet For Each wks In ActiveWorkbook.Worksheets On Error GoTo quit wks.Cells.Find(What:="test", After:=ActiveCell, LookIn:=xlFormulas, _ LookAt:=xlWhole, SearchOrder:=xlByColumns, _ SearchDirection:=xlNext, MatchCase:=False).Font.Name = "Times New Roman" Next wks quit: Exit Sub End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Find First Non blank cell than find column header and return that value | Excel Worksheet Functions | |||
Despite data existing in Excel 2002 spreadsheet Find doesn't find | Excel Discussion (Misc queries) | |||
find and delete duplicate entries in two columns or find and prin. | Excel Programming | |||
find and delete text, find a 10-digit number and put it in a textbox | Excel Programming | |||
backwards find function to find character in a string of text | Excel Programming |