ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Using results from XLDIALOG commands (https://www.excelbanter.com/excel-programming/390201-using-results-xldialog-commands.html)

don

Using results from XLDIALOG commands
 
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

Dave Peterson

Using results from XLDIALOG commands
 
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.

don wrote:

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


--

Dave Peterson


All times are GMT +1. The time now is 12:01 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com