ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Want to get text entered in a Userform TextBox after hitting Tab o (https://www.excelbanter.com/excel-programming/398287-want-get-text-entered-userform-textbox-after-hitting-tab-o.html)

MikeZz

Want to get text entered in a Userform TextBox after hitting Tab o
 
This is probably so basic I'll shoot myself but I can't get this simple
command to work.

Basically,
I have an empty box that the user can type a string in.
I want to use the string to create an autofilter.
I have all the code to apply the filter, I just need to get the string from
the text box.

inpPNa is the text box and I've tried:
FilterVal = inpPNa.value, FilterVal = inpPNa.text
and both times: FilterVal = ""

I want to make this as easy as possible so I'd like to run the code whenever
someone types something in the box and presses Enter or Tab.

If I can get the string, I can add the wildcards to it as shown below.

Thanks,

MikeZz

Private Sub inpPro_Change()
Dim FilterVal As String

If Len(inpPNa) < 0 Then
FilterVal = "ClearThisFilter"
Else
FilterVal = "=*" & inpPNa.Text & "*"
End If



Steve Yandl

Want to get text entered in a Userform TextBox after hitting Tab o
 
Try something like this.

Private Sub inpPNA_AfterUpdate()
myText = inpPNA.Text
MsgBox myText
End Sub


Steve



"MikeZz" wrote in message
...
This is probably so basic I'll shoot myself but I can't get this simple
command to work.

Basically,
I have an empty box that the user can type a string in.
I want to use the string to create an autofilter.
I have all the code to apply the filter, I just need to get the string
from
the text box.

inpPNa is the text box and I've tried:
FilterVal = inpPNa.value, FilterVal = inpPNa.text
and both times: FilterVal = ""

I want to make this as easy as possible so I'd like to run the code
whenever
someone types something in the box and presses Enter or Tab.

If I can get the string, I can add the wildcards to it as shown below.

Thanks,

MikeZz

Private Sub inpPro_Change()
Dim FilterVal As String

If Len(inpPNa) < 0 Then
FilterVal = "ClearThisFilter"
Else
FilterVal = "=*" & inpPNa.Text & "*"
End If





MikeZz

Want to get text entered in a Userform TextBox after hitting T
 
Hi Steve,
Just tried this and it doesn't work.
Msgbox is just blank.

I also tried removing the Form and macros, saving the file, then bringing it
back in... just in case it was corrupted and that also didn't help.

I also tried putting your code into a seperate button_click and it's also
blank so I have no idea what's going on.

Thanks

Any other ideas?

"Steve Yandl" wrote:

Try something like this.

Private Sub inpPNA_AfterUpdate()
myText = inpPNA.Text
MsgBox myText
End Sub


Steve



"MikeZz" wrote in message
...
This is probably so basic I'll shoot myself but I can't get this simple
command to work.

Basically,
I have an empty box that the user can type a string in.
I want to use the string to create an autofilter.
I have all the code to apply the filter, I just need to get the string
from
the text box.

inpPNa is the text box and I've tried:
FilterVal = inpPNa.value, FilterVal = inpPNa.text
and both times: FilterVal = ""

I want to make this as easy as possible so I'd like to run the code
whenever
someone types something in the box and presses Enter or Tab.

If I can get the string, I can add the wildcards to it as shown below.

Thanks,

MikeZz

Private Sub inpPro_Change()
Dim FilterVal As String

If Len(inpPNa) < 0 Then
FilterVal = "ClearThisFilter"
Else
FilterVal = "=*" & inpPNa.Text & "*"
End If






MikeZz

Want to get text entered in a Userform TextBox after hitting T
 
Hi Steve,
I tried creating a new text box and adding my code to it and it worked just
fine.
That text box must have somehow gotten corrupt.

Thanks again for your help!

"Steve Yandl" wrote:

Try something like this.

Private Sub inpPNA_AfterUpdate()
myText = inpPNA.Text
MsgBox myText
End Sub


Steve



"MikeZz" wrote in message
...
This is probably so basic I'll shoot myself but I can't get this simple
command to work.

Basically,
I have an empty box that the user can type a string in.
I want to use the string to create an autofilter.
I have all the code to apply the filter, I just need to get the string
from
the text box.

inpPNa is the text box and I've tried:
FilterVal = inpPNa.value, FilterVal = inpPNa.text
and both times: FilterVal = ""

I want to make this as easy as possible so I'd like to run the code
whenever
someone types something in the box and presses Enter or Tab.

If I can get the string, I can add the wildcards to it as shown below.

Thanks,

MikeZz

Private Sub inpPro_Change()
Dim FilterVal As String

If Len(inpPNa) < 0 Then
FilterVal = "ClearThisFilter"
Else
FilterVal = "=*" & inpPNa.Text & "*"
End If






Steve Yandl

Want to get text entered in a Userform TextBox after hitting T
 
That was a little strange. The fact that the message box came up at all
suggested you had the code in the right place and code was running in
response to the event. The good news is that it was just that text box with
the problem, not all future text boxes.

Steve


"MikeZz" wrote in message
...
Hi Steve,
I tried creating a new text box and adding my code to it and it worked
just
fine.
That text box must have somehow gotten corrupt.

Thanks again for your help!

"Steve Yandl" wrote:

Try something like this.

Private Sub inpPNA_AfterUpdate()
myText = inpPNA.Text
MsgBox myText
End Sub


Steve



"MikeZz" wrote in message
...
This is probably so basic I'll shoot myself but I can't get this simple
command to work.

Basically,
I have an empty box that the user can type a string in.
I want to use the string to create an autofilter.
I have all the code to apply the filter, I just need to get the string
from
the text box.

inpPNa is the text box and I've tried:
FilterVal = inpPNa.value, FilterVal = inpPNa.text
and both times: FilterVal = ""

I want to make this as easy as possible so I'd like to run the code
whenever
someone types something in the box and presses Enter or Tab.

If I can get the string, I can add the wildcards to it as shown below.

Thanks,

MikeZz

Private Sub inpPro_Change()
Dim FilterVal As String

If Len(inpPNa) < 0 Then
FilterVal = "ClearThisFilter"
Else
FilterVal = "=*" & inpPNa.Text & "*"
End If









All times are GMT +1. The time now is 05:16 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com