VBA code to find cell on worksheet with matching value to form control value (1 Viewer)

mdnc

New member
Local time
Today, 12:53
Joined
Jan 17, 2013
Messages
2
I have a button on a form in an Access 2007 DB that opens a large Excel sheet with some simple VBA code. I would like to add to the VBA code so it will search the worksheet after it opens for a cell that matches a value passed from a form control (text box), and then goes to that cell in the visible window. Essentially just using the VBA code to execute the Find function. I don't have a lot of experience with VBA and the Excel objects. Any help would be greatly appreciated!
 

ByteMyzer

AWF VIP
Local time
Today, 09:53
Joined
May 3, 2004
Messages
1,409
In your form's code, you can use something like:
Code:
    [B][I]xlApp[/I][/B].ActiveSheet.Cells.Find(What:=Me.[B][I]MyTextBox[/I][/B].Value, _
        After:=ActiveCell, _
        LookIn:=xlFormulas, _
        LookAt:=xlPart, _
        SearchOrder:=xlByRows, _
        SearchDirection:=xlNext, _
        MatchCase:=[COLOR="Navy"]False[/COLOR], _
        SearchFormat:=[COLOR="navy"]False[/COLOR]).Activate
...where xlApp is the reference to your Excel Application object, and MyTextBox is the name of your text box.
 

mdnc

New member
Local time
Today, 12:53
Joined
Jan 17, 2013
Messages
2
Worked perfect!!! Thank you very much!
 

Users who are viewing this thread

Top Bottom