Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hello
I would like to use an input box to find in my excel data base some information. I have been able to create the input box and the vba code to find a word or the sentence but if i put both together it doesn't work anymore. Could you please help me. The code which i have create is as follow: Sub Find() Dim rangeCel As Range Dim compt As Integer Dim fin As String fin = Application.InputBox(Prompt:="KUNDE", Type:=2) ActiveSheet.Range("$A$15:$n$500 ").AutoFilter Field:=1, Criteria1:="=*" & [H14].Value & "*" End Sub Thanks a lot Inès |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
The result from the inputbox is stored in the fin variable. Yous should replace [H14].value with "fin" and it should work perfect. ActiveSheet.Range("$A$15:$n$500 ").AutoFilter Field:=1, Criteria1:="=*" & fin & "*" if you have a changing number of rows in your database, you can make it more dynamic by: ActiveSheet.Range("$A$15).CurrentRegion.AutoFilter Field:=1, Criteria1:="=*" & fin & "*" this will only work, if you have no empty rows in your data. Furthermore range("A14:N14) shoud be empty cells to avoid these to be included into the currentregion. br Lazzzx "inès" skrev i meddelelsen ... Hello I would like to use an input box to find in my excel data base some information. I have been able to create the input box and the vba code to find a word or the sentence but if i put both together it doesn't work anymore. Could you please help me. The code which i have create is as follow: Sub Find() Dim rangeCel As Range Dim compt As Integer Dim fin As String fin = Application.InputBox(Prompt:="KUNDE", Type:=2) ActiveSheet.Range("$A$15:$n$500 ").AutoFilter Field:=1, Criteria1:="=*" & [H14].Value & "*" End Sub Thanks a lot Inès |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi, Inès
You can use the cod follow, to look for words and mark the same sentences with other color: Sub FindText() Dim strText As String Dim rngReturn As Range Dim strFirst As String strText = InputBox("Enter the texto to look for", "Find Text") Set rngReturn = Range("a2:i3000").Find(strText, LookIn:=xlValues) If Not rngReturn Is Nothing Then strFirst = rngReturn.Address Do rngReturn.Interior.Color = vbYellow Set rngReturn = Range("a2:i3000").FindNext(rngReturn) Loop While Not rngReturn Is Nothing And CStr(rngReturn.Address) < strFirst End If End Sub Sorry my english, because i don't speak very well!!!! bye!!! "inès" wrote: Hello I would like to use an input box to find in my excel data base some information. I have been able to create the input box and the vba code to find a word or the sentence but if i put both together it doesn't work anymore. Could you please help me. The code which i have create is as follow: Sub Find() Dim rangeCel As Range Dim compt As Integer Dim fin As String fin = Application.InputBox(Prompt:="KUNDE", Type:=2) ActiveSheet.Range("$A$15:$n$500 ").AutoFilter Field:=1, Criteria1:="=*" & [H14].Value & "*" End Sub Thanks a lot Inès |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hello Rodrigo F Rodrigues
Thanks for the macro. But i still have a small problem, i should sort out all the cells with the content of the input box. It i write "Hello" in the input box i should see all the cells with the word "Hello". But of course if the cells text is "Louis say Hello" it should appear also. Thanks a lot Louis "Rodrigo F Rodrigues" wrote: Hi, Inès You can use the cod follow, to look for words and mark the same sentences with other color: Sub FindText() Dim strText As String Dim rngReturn As Range Dim strFirst As String strText = InputBox("Enter the texto to look for", "Find Text") Set rngReturn = Range("a2:i3000").Find(strText, LookIn:=xlValues) If Not rngReturn Is Nothing Then strFirst = rngReturn.Address Do rngReturn.Interior.Color = vbYellow Set rngReturn = Range("a2:i3000").FindNext(rngReturn) Loop While Not rngReturn Is Nothing And CStr(rngReturn.Address) < strFirst End If End Sub Sorry my english, because i don't speak very well!!!! bye!!! "inès" wrote: Hello I would like to use an input box to find in my excel data base some information. I have been able to create the input box and the vba code to find a word or the sentence but if i put both together it doesn't work anymore. Could you please help me. The code which i have create is as follow: Sub Find() Dim rangeCel As Range Dim compt As Integer Dim fin As String fin = Application.InputBox(Prompt:="KUNDE", Type:=2) ActiveSheet.Range("$A$15:$n$500 ").AutoFilter Field:=1, Criteria1:="=*" & [H14].Value & "*" End Sub Thanks a lot Inès |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Dear Lazzzx
Thanks a lot, now it work "Lazzzx" wrote: Hi, The result from the inputbox is stored in the fin variable. Yous should replace [H14].value with "fin" and it should work perfect. ActiveSheet.Range("$A$15:$n$500 ").AutoFilter Field:=1, Criteria1:="=*" & fin & "*" if you have a changing number of rows in your database, you can make it more dynamic by: ActiveSheet.Range("$A$15).CurrentRegion.AutoFilter Field:=1, Criteria1:="=*" & fin & "*" this will only work, if you have no empty rows in your data. Furthermore range("A14:N14) shoud be empty cells to avoid these to be included into the currentregion. br Lazzzx "inès" skrev i meddelelsen ... Hello I would like to use an input box to find in my excel data base some information. I have been able to create the input box and the vba code to find a word or the sentence but if i put both together it doesn't work anymore. Could you please help me. The code which i have create is as follow: Sub Find() Dim rangeCel As Range Dim compt As Integer Dim fin As String fin = Application.InputBox(Prompt:="KUNDE", Type:=2) ActiveSheet.Range("$A$15:$n$500 ").AutoFilter Field:=1, Criteria1:="=*" & [H14].Value & "*" End Sub Thanks a lot Inès |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
input in number form is being multiplied by 1000 when i input. | Excel Discussion (Misc queries) | |||
Have user input converted to uppercase in same cell as input? | New Users to Excel | |||
How do I add input data in the input ranges in drop down boxes. | Excel Discussion (Misc queries) | |||
=SUMIF(Input!H2:H718,AZ19,Input!E2:E685)AND(IF | Excel Worksheet Functions | |||
CODE to select range based on User Input or Value of Input Field | Excel Programming |