text box validation needed

VBABEGINER

Well-known Member
Joined
Jun 15, 2011
Messages
1,232
Dear Team,
I need validation text box, in a such way that user can only paste. No manual entry.
Can it be possible..
Answer = Yes, with MrExcel..!!:)

Pls suggest
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Setting the .DragBehaviour to 1 will enable the paste ability.
You can prevent the user from typing into a text box with code like this.
Code:
Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
    KeyAscii = 0
End Sub
 
Upvote 0
Thanks..But want to add this condition too..apologies..I forgot to explain
Code:
Private Sub TxtCaseID_AfterUpdate()
If Len(TxtCaseID.Value) < 5 Then
MsgBox "Case id not less than 5 number"
End If
End Sub

Ok, I will keep both..
 
Last edited:
Upvote 0
If you set the MaxLength of the textbox to 5, it will truncate any other characters that are pasted into it.

Also, I can't help thinking that you might prefer a ComboBox. If you are copy/pasting from a list of Case IDs, it might be easier to use a ComboBox (or Listbox) with its entries drawn from the same source as the copy/paste. Save the user having to c/p. Save you having to tweek a TextBox.
 
Upvote 0
Thanks for the idea, but its the manager requirement to copy paste only.. The code number will be in another application. from there copy-paste activity will be there.
 
Upvote 0

Forum statistics

Threads
1,214,657
Messages
6,120,775
Members
448,991
Latest member
Hanakoro

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