473,395 Members | 1,629 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Find/next input box with yes/no selection and message box result

Im trying to create a input box in excel asking for a text, then lookup the text.

Since more than one row may contain part of the text, then the mmesage box will ask if what wqs found is correct or not. If not, then find next.

If answwer s yes, then display message box with data contain in more than one cell within the row.

I have been searching the forums and this is what I was able to put together.This is two different codes I found and tried to make them work as one.

Expand|Select|Wrap|Line Numbers
  1. Sub SearchAccount()
  2. Dim vResult1, vResult2
  3. Dim rFound As Range
  4. Dim Lookfor As String
  5.  
  6. Lookfor = InputBox("Enter Account Title", "Search")
  7. If Lookfor = "" Then
  8.   End
  9. End If
  10.  
  11. On Error Resume Next
  12. With Sheet1.Range("H:H") 'Sheet1 is the CodeName
  13.     Set rFound = .Find _
  14.         (What:=Lookfor, After:=.Cells(1, 1), LookIn:=xlValues, LookAt:=xlWhole)
  15. End With
  16.  
  17. Flag1:
  18. If Not Cells.Find(What:=Lookfor, After:=ActiveCell, LookIn:=xlFormulas, LookAt _
  19.     :=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
  20.     False, SearchFormat:=False) Is Nothing Then
  21.  
  22.   Cells.Find(What:=Lookfor, After:=ActiveCell, LookIn:=xlFormulas, LookAt _
  23.       :=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
  24.       False, SearchFormat:=False).Activate
  25.  
  26.   If MsgBox("Is this the correct Account?", vbYesNo) <> vbYes Then
  27.     GoTo Flag1
  28.   End If
  29.  
  30. If rFound Is Nothing Then
  31.    MsgBox "For Account Number : " _
  32. & rFound(1, 2) & " , the Banker name is : " & rFound(1, 3)
  33.  End If
  34.  
  35. Else 
  36.   MsgBox ("The Account Title is not in the list") 
  37.  
  38.  End If
  39. End Sub
  40.  

This does not seems to work for answer "YES", instead it display only the "For Account Number : " but not the line below

I got some of your code from

http://bytes.com/topic/visual-basic/...next-input-box
Oct 5 '10 #1
1 1844
Guido Geurs
767 Expert 512MB
This code will search a value in a range. (see attachment).
If You want more help, please attach in BYTES the XLS so we can work more directly on this project.
Oct 6 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Jenny | last post by:
Hi, When I input my email address on this website, it provides a drop down box with two of my email addresses. The right bottom corner has a few 45 degree lines to indicate the user can change...
0
by: Brian Nielsen | last post by:
Hi I'm making a msi module through Visual Studio -> Deployment project. I have added a standard Textboxes user interface to the user interface list and written something like: Edit1Label: ...
2
by: yawnmoth | last post by:
Say I have two input elements and that I wanted to make it so that when the first ones input was what it should be, the focus would automatically be shifted to the next input element. ie....
2
by: ntsNews | last post by:
Hi, Using the built in command "Find Next" is there a way to have the Match Drop Down Menu to default to "Start of Field"... or can it be the only option? GCM
1
by: GoDogGo | last post by:
I need code to find next Tuesdays date. I have started with this: TuesdaysDate = DateAdd("d", vbTuesday - Weekday(Date), Date) However if today is Wednesday it returns yesterdays date. I...
1
by: babyjek | last post by:
SELECT ProjectID, ProjectName, ProjectDescription, SequenceNumber, LastUpdateDate FROM Project WHERE ProjectID = @ProjectID; (The Microsoft Jet database engine cannot find the input table or...
0
by: Jim Richards | last post by:
Hello All. Using XP Pro w/SP4 and Visual Studio 2003. I have the "FIND LOT" and "FIND BY OWNERS LAST NAME" working fine now. But I can only find the first occurance of the last name typed into the...
6
by: warpcon | last post by:
Im trying to build a database starting with one of the templates that come with access. I took out the employee part in all the tables and forms. Now when I pull up a workorder and then try to view...
7
Walt in Decatur
by: Walt in Decatur | last post by:
I'm trying to use this method to copy an range in Excel workbook that is closed to the one that's open. I'm using the following code, which gets the "Can't find installable ISAM" error when I get to...
0
by: mustakbal | last post by:
I am using this code to search with wild cards for strings in a text file. I wanted to improve the application by adding a "Find Next " button that will display the rest of the strings that the...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.