Using results from XLDIALOG commands

D

don

The following command shows the Find Dialog box but how do I capture
the results of that search.

Application.Dialogs(xlDialogFormulaFind).Show

If I try set stuff = Application.Dialogs(xlDialogFormulaFind).Show
I get an error.

If I try stuff = Application.Dialogs(xlDialogFormulaFind).Show
I get true or false.

I'd like to find the cell that has the data and then capture that
cells attributes, ie address, row, column, etc.

Where can I find examples of using the results of what the dialog box
found. Help shows what attributes to feed the boxes but I can't find
where to capture the results of the search.

Thanks for any help.

Don
 
D

Dave Peterson

I don't think you can use that dialog that way.

Maybe you could build your own find?

Option Explicit
Sub testme01()
Dim WhatToFind As String
Dim FoundCell As Range

WhatToFind = Inputbox(Prompt:="What:")
if whattofind = "" then
exit sub
end if

'you can even limit your range
With ActiveSheet.Range("a1:b99")
'or all the cells
'With ActiveSheet.cells
Set FoundCell = .Cells.Find(What:=WhatToFind, _
After:=.Cells(.Cells.Count), _
LookIn:=xlValues, _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)

If FoundCell Is Nothing Then
Msgbox "Not found"
Else
Msgbox Foundcell.address & vblf & _
foundcell.row & vblf & foundcell.column
End If
End With
End Sub

You'll want to specify the parms in the .Find() command, too. Record a macro
when you use the settings you want and you'll see the code you need.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top