Find Search Dialog Box The Only Searches For Bold Text

miketurn

Active Member
Joined
Dec 8, 2016
Messages
268
Does anyone by any chance have a macro that can do the following?

1.) Call up a dialog box with a find (search) field
2.) User types in desired search for BOLD text items only
3.) Searches for and finds the first BOLD text item instance
4.) Closes dialog box automatically
5.) Navigates cursor to that cell containing the BOLD text search result

Thank You
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Something like this?
Code:
 Sub Srch()

    Dim Ans As String
    
    Ans = Application.InputBox("Enter the item you want to look for")
    If Len(Ans) = 0 Then
        MsgBox "Nothing entered"
        Exit Sub
    ElseIf Ans = False Then
        MsgBox "Clicked Cancel"
        Exit Sub
    End If
    Application.FindFormat.Font.FontStyle = "Bold"
    On Error Resume Next
    Cells.Find(What:=Ans, After:=ActiveCell, LookIn:=xlFormulas, LookAt _
        :=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
        False, SearchFormat:=True).Activate
    ActiveWindow.ScrollRow = ActiveCell.Row


End Sub
 
Upvote 0
@Fluff
Thank you for your response, I tried out the macro you supplied but unfortunately I ran into an error.

Code:
Run-time error '13'
Type mismatch

When "debug" is run it highlights the following line of code
Code:
ElseIf Ans = False Then

Not sure if it matters, but I am running 2003 at the moment.

Thanks again
 
Upvote 0
My mistake, try
Code:
Sub Srch()

    Dim Ans As Variant
    
    Ans = Application.InputBox("Enter the item you want to look for")
    If Len(Ans) = 0 Then
        MsgBox "Nothing entered"
        Exit Sub
    ElseIf Ans = False Then
        MsgBox "Clicked Cancel"
        Exit Sub
    End If
    Application.FindFormat.Font.FontStyle = "Bold"
    On Error Resume Next
    Cells.Find(What:=Ans, After:=ActiveCell, LookIn:=xlFormulas, LookAt _
        :=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
        False, SearchFormat:=True).Activate
    ActiveWindow.ScrollRow = ActiveCell.Row


End Sub
 
Upvote 0
My mistake, try
Code:
Sub Srch()

    Dim Ans As Variant
    
    Ans = Application.InputBox("Enter the item you want to look for")
    If Len(Ans) = 0 Then
        MsgBox "Nothing entered"
        Exit Sub
    ElseIf Ans = False Then
        MsgBox "Clicked Cancel"
        Exit Sub
    End If
    [B][COLOR="#FF0000"]Application.FindFormat.Clear[/COLOR][/B]
    Application.FindFormat.Font.FontStyle = "Bold"
    On Error Resume Next
    Cells.Find(What:=Ans, After:=ActiveCell, LookIn:=xlFormulas, LookAt _
        :=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
        False, SearchFormat:=True).Activate
    ActiveWindow.ScrollRow = ActiveCell.Row
    [B][COLOR="#FF0000"]Application.FindFormat.Clear[/COLOR][/B]

End Sub
Just to be safe, you should include the first code line I show in red above. The Find function, as well as the Excel Find dialog box, "remembers" the search format criteria from the last time text was searched for using either Excel's Find dialog box or VBA's Find function. Since the Find format criteria are cumulative, if a search format criteria for something other than Font.FontStyle was last in effect, it will still be in effect along with your new search format criteria. The second code line in red is to be kind to the user by not leaving a search format criteria in effect that he may not know is there the next time he uses the Find dialog box.
 
Upvote 0
@Fluff
Thank You for your updated macro, no problem, I gave the new macro a try along with the added updates from Rick and so far everything works great.
@Rick Rothstein
As always Rick, thank you for your continued help.
 
Upvote 0
Glad we could help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,286
Members
452,631
Latest member
a_potato

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top