Excel dynamic search vba code











up vote
0
down vote

favorite












With this VBA macro for Excel I get instant search filter when I type the whole word, but I want it as follows: when I type O for opel, that I get opel already showing.



This is the code:



Sub MG26Nov26
Private Sub TextBox1_Change()
Dim Ray As Variant
If Len(TextBox1.Value) = 0 Then
Sheet1.AutoFilterMode = False
Else
If Sheet1.AutoFilterMode = True Then
Sheet1.AutoFilterMode = False
End If
Ray = Split(TextBox1, "+")
Sheet1.Range("A2:F" & Rows.Count).AutoFilter field:=1, Criteria1:=Ray, Operator:=xlFilterValues
End If

End Sub


This is the test file:



https://drive.google.com/open?id=1KDwE2jT_u35wPhd5dR7Xi3X31ddzXDNx










share|improve this question
























  • Try changing ray to Ray = Split(TextBox1 & "*", "+")
    – Christofer Weber
    Nov 28 at 0:06










  • This worked for me too. You have really excel skills! thank you very much
    – Louai Al Falahi
    Nov 28 at 16:07















up vote
0
down vote

favorite












With this VBA macro for Excel I get instant search filter when I type the whole word, but I want it as follows: when I type O for opel, that I get opel already showing.



This is the code:



Sub MG26Nov26
Private Sub TextBox1_Change()
Dim Ray As Variant
If Len(TextBox1.Value) = 0 Then
Sheet1.AutoFilterMode = False
Else
If Sheet1.AutoFilterMode = True Then
Sheet1.AutoFilterMode = False
End If
Ray = Split(TextBox1, "+")
Sheet1.Range("A2:F" & Rows.Count).AutoFilter field:=1, Criteria1:=Ray, Operator:=xlFilterValues
End If

End Sub


This is the test file:



https://drive.google.com/open?id=1KDwE2jT_u35wPhd5dR7Xi3X31ddzXDNx










share|improve this question
























  • Try changing ray to Ray = Split(TextBox1 & "*", "+")
    – Christofer Weber
    Nov 28 at 0:06










  • This worked for me too. You have really excel skills! thank you very much
    – Louai Al Falahi
    Nov 28 at 16:07













up vote
0
down vote

favorite









up vote
0
down vote

favorite











With this VBA macro for Excel I get instant search filter when I type the whole word, but I want it as follows: when I type O for opel, that I get opel already showing.



This is the code:



Sub MG26Nov26
Private Sub TextBox1_Change()
Dim Ray As Variant
If Len(TextBox1.Value) = 0 Then
Sheet1.AutoFilterMode = False
Else
If Sheet1.AutoFilterMode = True Then
Sheet1.AutoFilterMode = False
End If
Ray = Split(TextBox1, "+")
Sheet1.Range("A2:F" & Rows.Count).AutoFilter field:=1, Criteria1:=Ray, Operator:=xlFilterValues
End If

End Sub


This is the test file:



https://drive.google.com/open?id=1KDwE2jT_u35wPhd5dR7Xi3X31ddzXDNx










share|improve this question















With this VBA macro for Excel I get instant search filter when I type the whole word, but I want it as follows: when I type O for opel, that I get opel already showing.



This is the code:



Sub MG26Nov26
Private Sub TextBox1_Change()
Dim Ray As Variant
If Len(TextBox1.Value) = 0 Then
Sheet1.AutoFilterMode = False
Else
If Sheet1.AutoFilterMode = True Then
Sheet1.AutoFilterMode = False
End If
Ray = Split(TextBox1, "+")
Sheet1.Range("A2:F" & Rows.Count).AutoFilter field:=1, Criteria1:=Ray, Operator:=xlFilterValues
End If

End Sub


This is the test file:



https://drive.google.com/open?id=1KDwE2jT_u35wPhd5dR7Xi3X31ddzXDNx







microsoft-excel vba macros






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 27 at 22:30









Worthwelle

2,2593824




2,2593824










asked Nov 27 at 18:18









Louai Al Falahi

32




32












  • Try changing ray to Ray = Split(TextBox1 & "*", "+")
    – Christofer Weber
    Nov 28 at 0:06










  • This worked for me too. You have really excel skills! thank you very much
    – Louai Al Falahi
    Nov 28 at 16:07


















  • Try changing ray to Ray = Split(TextBox1 & "*", "+")
    – Christofer Weber
    Nov 28 at 0:06










  • This worked for me too. You have really excel skills! thank you very much
    – Louai Al Falahi
    Nov 28 at 16:07
















Try changing ray to Ray = Split(TextBox1 & "*", "+")
– Christofer Weber
Nov 28 at 0:06




Try changing ray to Ray = Split(TextBox1 & "*", "+")
– Christofer Weber
Nov 28 at 0:06












This worked for me too. You have really excel skills! thank you very much
– Louai Al Falahi
Nov 28 at 16:07




This worked for me too. You have really excel skills! thank you very much
– Louai Al Falahi
Nov 28 at 16:07










1 Answer
1






active

oldest

votes

















up vote
0
down vote



accepted










To solve the issue, you can use the below written VBA code.



Private Sub TextBox1_Change()
Dim Ray As Variant
If Len(TextBox1.Value) = 0 Then
Sheet1.AutoFilterMode = False
Else
If Sheet1.AutoFilterMode = True Then
Sheet1.AutoFilterMode = False
End If

Sheet1.Range("A2:F" & Rows.Count).AutoFilter field:=1, Criteria1:="*" & TextBox1.Text & "*", Operator:=xlFilterValues
End If

End Sub


N.B. This is the Change I've done in the VBA Code Criteria1:="*" & TextBox1.Text & "*" in place of the Ray variable.






share|improve this answer





















  • Woowww that worked for me.Thank your very much!!
    – Louai Al Falahi
    Nov 28 at 16:06












  • @LouaiAlFalahi,, glad to help you and happy to learn that my solution worked for you. If you wish accept it as Answer also you can up vote it ☺
    – Rajesh S
    Nov 29 at 6:55











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1378851%2fexcel-dynamic-search-vba-code%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
0
down vote



accepted










To solve the issue, you can use the below written VBA code.



Private Sub TextBox1_Change()
Dim Ray As Variant
If Len(TextBox1.Value) = 0 Then
Sheet1.AutoFilterMode = False
Else
If Sheet1.AutoFilterMode = True Then
Sheet1.AutoFilterMode = False
End If

Sheet1.Range("A2:F" & Rows.Count).AutoFilter field:=1, Criteria1:="*" & TextBox1.Text & "*", Operator:=xlFilterValues
End If

End Sub


N.B. This is the Change I've done in the VBA Code Criteria1:="*" & TextBox1.Text & "*" in place of the Ray variable.






share|improve this answer





















  • Woowww that worked for me.Thank your very much!!
    – Louai Al Falahi
    Nov 28 at 16:06












  • @LouaiAlFalahi,, glad to help you and happy to learn that my solution worked for you. If you wish accept it as Answer also you can up vote it ☺
    – Rajesh S
    Nov 29 at 6:55















up vote
0
down vote



accepted










To solve the issue, you can use the below written VBA code.



Private Sub TextBox1_Change()
Dim Ray As Variant
If Len(TextBox1.Value) = 0 Then
Sheet1.AutoFilterMode = False
Else
If Sheet1.AutoFilterMode = True Then
Sheet1.AutoFilterMode = False
End If

Sheet1.Range("A2:F" & Rows.Count).AutoFilter field:=1, Criteria1:="*" & TextBox1.Text & "*", Operator:=xlFilterValues
End If

End Sub


N.B. This is the Change I've done in the VBA Code Criteria1:="*" & TextBox1.Text & "*" in place of the Ray variable.






share|improve this answer





















  • Woowww that worked for me.Thank your very much!!
    – Louai Al Falahi
    Nov 28 at 16:06












  • @LouaiAlFalahi,, glad to help you and happy to learn that my solution worked for you. If you wish accept it as Answer also you can up vote it ☺
    – Rajesh S
    Nov 29 at 6:55













up vote
0
down vote



accepted







up vote
0
down vote



accepted






To solve the issue, you can use the below written VBA code.



Private Sub TextBox1_Change()
Dim Ray As Variant
If Len(TextBox1.Value) = 0 Then
Sheet1.AutoFilterMode = False
Else
If Sheet1.AutoFilterMode = True Then
Sheet1.AutoFilterMode = False
End If

Sheet1.Range("A2:F" & Rows.Count).AutoFilter field:=1, Criteria1:="*" & TextBox1.Text & "*", Operator:=xlFilterValues
End If

End Sub


N.B. This is the Change I've done in the VBA Code Criteria1:="*" & TextBox1.Text & "*" in place of the Ray variable.






share|improve this answer












To solve the issue, you can use the below written VBA code.



Private Sub TextBox1_Change()
Dim Ray As Variant
If Len(TextBox1.Value) = 0 Then
Sheet1.AutoFilterMode = False
Else
If Sheet1.AutoFilterMode = True Then
Sheet1.AutoFilterMode = False
End If

Sheet1.Range("A2:F" & Rows.Count).AutoFilter field:=1, Criteria1:="*" & TextBox1.Text & "*", Operator:=xlFilterValues
End If

End Sub


N.B. This is the Change I've done in the VBA Code Criteria1:="*" & TextBox1.Text & "*" in place of the Ray variable.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 28 at 7:46









Rajesh S

3,5111422




3,5111422












  • Woowww that worked for me.Thank your very much!!
    – Louai Al Falahi
    Nov 28 at 16:06












  • @LouaiAlFalahi,, glad to help you and happy to learn that my solution worked for you. If you wish accept it as Answer also you can up vote it ☺
    – Rajesh S
    Nov 29 at 6:55


















  • Woowww that worked for me.Thank your very much!!
    – Louai Al Falahi
    Nov 28 at 16:06












  • @LouaiAlFalahi,, glad to help you and happy to learn that my solution worked for you. If you wish accept it as Answer also you can up vote it ☺
    – Rajesh S
    Nov 29 at 6:55
















Woowww that worked for me.Thank your very much!!
– Louai Al Falahi
Nov 28 at 16:06






Woowww that worked for me.Thank your very much!!
– Louai Al Falahi
Nov 28 at 16:06














@LouaiAlFalahi,, glad to help you and happy to learn that my solution worked for you. If you wish accept it as Answer also you can up vote it ☺
– Rajesh S
Nov 29 at 6:55




@LouaiAlFalahi,, glad to help you and happy to learn that my solution worked for you. If you wish accept it as Answer also you can up vote it ☺
– Rajesh S
Nov 29 at 6:55


















draft saved

draft discarded




















































Thanks for contributing an answer to Super User!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1378851%2fexcel-dynamic-search-vba-code%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Probability when a professor distributes a quiz and homework assignment to a class of n students.

Aardman Animations

Are they similar matrix