Remove Value from TextBox if another Textbox is selected

ipbr21054

Well-known Member
Joined
Nov 16, 2010
Messages
5,832
Office Version
  1. 2007
Platform
  1. Windows
Hi,
Im not sure what the procedure is called but,

On my userform i Have 2 Textboxes.
TextBox8 & TextBox11

If i click in TextBox8 & type a value but then click in TextBox11 im looking to have that typed value removed.
Cant think of procedure name to use.

Something like If TextBox8 has Focus Then ???
Please advise
 
That didnt work so the text in the opposite TextBox is still there
 
Upvote 0

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
Are you looking to do the opposite of original post?
VBA Code:
Private Sub TextBox11_BeforeUpdate()
Me.TextBox8.Value = ""
End Sub
 
Upvote 0
As a test i used this,

VBA Code:
    Private Sub TextBox8_AfterUpdate()
        Me.TextBox11.Value = "1"
    End Sub

I type a value in TextBox8 then click in TextBox11
In textBox11 i see the number 1
The text from textbox8 is removed

Does that help
 
Upvote 0
Are you looking to do the opposite of original post?
VBA Code:
Private Sub TextBox11_AfterUpdate()
Me.TextBox8.Value = ""
End Sub
I have 2 Textboxes, TextBox8 & TextBox11

I type a value in TextBox8 BUT what i want to happen is when i click in TextBox11 the value that was just typed in TextBox have it removed
The vice versa the other way around so both work
 
Upvote 0
I edited my reply. Double check post #12.
Compile error

EaseUS_2024_11_ 8_23_37_25.jpg
 
Upvote 0
You mean this ?

VBA Code:
    Private Sub TextBox8_BeforeUpdate()
        Me.TextBox11.Value = ""
    End Sub
    Private Sub TextBox11_BeforeUpdate()
        Me.TextBox8.Value = ""
    End Sub
 
Upvote 0
You mean this ?

VBA Code:
    Private Sub TextBox8_BeforeUpdate()
        Me.TextBox11.Value = ""
    End Sub
    Private Sub TextBox11_BeforeUpdate()
        Me.TextBox8.Value = ""
    End Sub
Yes. That gives you compile error?
 
Upvote 0
So i dont see what you mean then as i copied what was in #12 then did the same but reversed the 8 & 11
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,155
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top