Asa, Agree about the “undue attention”. My experience tells me that just leaving it out ( as I did) serves the purpose. Maybe you can time it.??
Don Guillett SalesAid Software dguille...@gmail.com From: Asa Rossoff Sent: Tuesday, February 21, 2012 2:10 PM To: excel-macros@googlegroups.com Subject: RE: $$Excel-Macros$$ Help with code please. Too true Don// .Find finds the first match… and stops. However, with all the undue attention to this code, I will offer a suggested update. The Set mg = .Cells.Find lines can be changed to the following to prevent an oft-overlooked issue with .Find. The issue is that .Find does not start searching from the beginning of a range, but from the cell after the first cell in the range. In the code provided so far, if a match is in A1 and also in another cell on the sheet, the code will never find the match in A1, but only the first match in a cell other than A1 (starting from B1). This change will start searching from A1: Set mf = .Cells.Find(What:="whattolookfor", ", After:=.Cells(.Rows.Count, .Columns.Count), LookIn:=xlValues, _ LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext) Asa From: excel-macros@googlegroups.com [mailto:excel-macros@googlegroups.com] On Behalf Of dguillett1 Sent: Tuesday, February 21, 2012 11:42 AM To: excel-macros@googlegroups.com Subject: Re: $$Excel-Macros$$ Help with code please. Sam, The code I provided does stop the macro with the selection. Yes, goto could be used but OP said select sheet select cell so I did that. “6 of one is 1/2 dozen of another” Don Guillett SalesAid Software dguille...@gmail.com From: Sam Mathai Chacko Sent: Tuesday, February 21, 2012 11:39 AM To: excel-macros@googlegroups.com Subject: Re: $$Excel-Macros$$ Help with code please. You'd want to exit the routine if the cell is found. Also, you can use application.goto to select the cell. I would also be weary about hidden sheets if any. Sub lookinallsheets() Dim wks As Worksheet Dim rng As Range For Each wks In Worksheets With wks Set rng = .Cells.Find(What:="whattolookfor", LookIn:=xlValues, LookAt:=xlWhole) If Not rng Is Nothing Then Application.Goto rng Exit For End If End With Next wks End Sub Regards, Sam Mathai Chacko On Tue, Feb 21, 2012 at 8:03 PM, dguillett1 <dguille...@gmail.com> wrote: This will look in all sheets in the file and select if found. Put it in your DIR loop for all files in the folder. Sub lookinallsheets() For Each ws In Worksheets With ws Set mf = .Cells.Find(What:="whattolookfor", LookIn:=xlValues, _ LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext) If Not mf Is Nothing Then .Select mf.Select End If End With Next ws End Sub Don Guillett SalesAid Software dguille...@gmail.com -----Original Message----- From: Bob Sent: Monday, February 20, 2012 2:28 PM To: MS EXCEL AND VBA MACROS Subject: Re: $$Excel-Macros$$ Help with code please. There will never be more than 1 of the same number. I just need it to select the sheet that it's on and then select the cell where it's located. Thanks in Advance On Feb 19, 8:58 am, "dguillett1" <dguille...@gmail.com> wrote: If you are saying you want to look for it on all sheets you can wrap in a loop for each ws in worksheets ws.Select Cells.Find(What:=IndividualSearch, LookIn:=xlValues,LookAt:=xlWhole).Activate next ws Or, are you saying there could be more than ONE hit?? BTW you don't need to select to work with the found item. More info?? Don Guillett SalesAid Software dguille...@gmail.com -----Original Message----- From: Bob Sent: Sunday, February 19, 2012 6:33 AM To: MS EXCEL AND VBA MACROS Subject: $$Excel-Macros$$ Help with code please. I almost have the code the way I need it. BUT I want it to Find everything within in the same Workbook, not just on the Index Worksheet. Thanks in advance!!! Private Sub CommandButton1_Click() Dim IndividualSearch As String IndividualSearch = InputBox("What's the part number you're looking for?", "Name Search entry box.") If IndividualSearch = "" Then Exit Sub On Error GoTo ErrorHandler Worksheets("Index").Select Cells.Find(What:=IndividualSearch, LookIn:=xlValues, LookAt:=xlWhole).Activate Exit Sub ErrorHandler: MsgBox IndividualSearch & " not found.", 64, "No such animal." End Sub -- FORUM RULES (986+ members already BANNED for violation) 1) Use concise, accurate thread titles. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get quick attention or may not be answered. 2) Don't post a question in the thread of another member. 3) Don't post questions regarding breaking or bypassing any security measure. 4) Acknowledge the responses you receive, good or bad. 5) Cross-promotion of, or links to, forums competitive to this forum in signatures are prohibited. NOTE : Don't ever post personal or confidential data in a workbook. Forum owners and members are not responsible for any loss. ------------------------------------------------------------------------------------------------------ To post to this group, send email to excel-macros@googlegroups.com- Hide quoted text - - Show quoted text - -- FORUM RULES (986+ members already BANNED for violation) 1) Use concise, accurate thread titles. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get quick attention or may not be answered. 2) Don't post a question in the thread of another member. 3) Don't post questions regarding breaking or bypassing any security measure. 4) Acknowledge the responses you receive, good or bad. 5) Cross-promotion of, or links to, forums competitive to this forum in signatures are prohibited. NOTE : Don't ever post personal or confidential data in a workbook. Forum owners and members are not responsible for any loss. ------------------------------------------------------------------------------------------------------ To post to this group, send email to excel-macros@googlegroups.com -- FORUM RULES (986+ members already BANNED for violation) 1) Use concise, accurate thread titles. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get quick attention or may not be answered. 2) Don't post a question in the thread of another member. 3) Don't post questions regarding breaking or bypassing any security measure. 4) Acknowledge the responses you receive, good or bad. 5) Cross-promotion of, or links to, forums competitive to this forum in signatures are prohibited. NOTE : Don't ever post personal or confidential data in a workbook. Forum owners and members are not responsible for any loss. ------------------------------------------------------------------------------------------------------ To post to this group, send email to excel-macros@googlegroups.com -- Sam Mathai Chacko -- FORUM RULES (986+ members already BANNED for violation) 1) Use concise, accurate thread titles. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get quick attention or may not be answered. 2) Don't post a question in the thread of another member. 3) Don't post questions regarding breaking or bypassing any security measure. 4) Acknowledge the responses you receive, good or bad. 5) Cross-promotion of, or links to, forums competitive to this forum in signatures are prohibited. NOTE : Don't ever post personal or confidential data in a workbook. Forum owners and members are not responsible for any loss. ------------------------------------------------------------------------------------------------------ To post to this group, send email to excel-macros@googlegroups.com -- FORUM RULES (986+ members already BANNED for violation) 1) Use concise, accurate thread titles. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get quick attention or may not be answered. 2) Don't post a question in the thread of another member. 3) Don't post questions regarding breaking or bypassing any security measure. 4) Acknowledge the responses you receive, good or bad. 5) Cross-promotion of, or links to, forums competitive to this forum in signatures are prohibited. NOTE : Don't ever post personal or confidential data in a workbook. Forum owners and members are not responsible for any loss. ------------------------------------------------------------------------------------------------------ To post to this group, send email to excel-macros@googlegroups.com -- FORUM RULES (986+ members already BANNED for violation) 1) Use concise, accurate thread titles. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get quick attention or may not be answered. 2) Don't post a question in the thread of another member. 3) Don't post questions regarding breaking or bypassing any security measure. 4) Acknowledge the responses you receive, good or bad. 5) Cross-promotion of, or links to, forums competitive to this forum in signatures are prohibited. NOTE : Don't ever post personal or confidential data in a workbook. Forum owners and members are not responsible for any loss. ------------------------------------------------------------------------------------------------------ To post to this group, send email to excel-macros@googlegroups.com -- FORUM RULES (986+ members already BANNED for violation) 1) Use concise, accurate thread titles. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get quick attention or may not be answered. 2) Don't post a question in the thread of another member. 3) Don't post questions regarding breaking or bypassing any security measure. 4) Acknowledge the responses you receive, good or bad. 5) Cross-promotion of, or links to, forums competitive to this forum in signatures are prohibited. NOTE : Don't ever post personal or confidential data in a workbook. Forum owners and members are not responsible for any loss. ------------------------------------------------------------------------------------------------------ To post to this group, send email to excel-macros@googlegroups.com