Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel 2007 VBA code find name and select it

Status
Not open for further replies.

DougP

MIS
Dec 13, 1999
5,985
US
I have this code I got from internet but can 't seem to make it select just the cell not the whole column/range.
Code:
    StudentName = InputBox("Enter Student Name:", "Find Student")
    Set FirstSheet = ActiveSheet '< bookmark start sheet
        For Each Ws In Worksheets
            Ws.Select
            With ActiveSheet.Cells
                Set FirstAddress = .Find(What:=StudentName, LookIn:=xlValues)
                If FirstAddress Is Nothing Then '< blank sheet
                    GoTo NextSheet
                Else
                    'found it
                    FirstAddress.CurrentRegion.Select ' < what do I change this too?
                    
                End If
                
            End With

NextSheet:
    Next Ws

I just want to prompt for a name and have it jump to that cell and highlight it, I need to search the entire workbook.

TIA

DougP
 

doug, doug, doug,

You ought to know by now

forum707

What do you intend to do when the cell is selected?

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Sorry man getting too old to remember anything anymore.
I figured it out though

FirstAddress.Activate

I just want to highlight it for the enduser.
we have 9 grades each on its own sheet and some people me included have not memorized which grade each of the 165 children are in.
we just need to find them quickly.
so this works now.


DougP
 


Code:
    StudentName = InputBox("Enter Student Name:", "Find Student")
    Set FirstSheet = ActiveSheet '< bookmark start sheet
        For Each Ws In Worksheets
            with Ws
               .Activate
               With .Cells
                Set FirstAddress = .Find(What:=StudentName, LookIn:=xlValues)
                If Not FirstAddress Is Nothing Then 
                     'found it
                    FirstAddress.Select 
                    Exit Sub
                End If
                
            End With
    Next Ws


Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top