Chewyhairball
Active Member
- Joined
- Nov 30, 2017
- Messages
- 312
- Office Version
- 365
- Platform
- Windows
Hi
I have this bit of code that Textbox2(called row2 on my user form) that displays a message box if no data has been entered into the textbox, and it works fine.
I have been trying to create a similar things but to display a message box if the data entered into the textbox is 'text or space' and not a number.
It doesnt work and triggers the message box whether i enter a number or text or a space.
Any help would be much appreciated.
I have this bit of code that Textbox2(called row2 on my user form) that displays a message box if no data has been entered into the textbox, and it works fine.
VBA Code:
If Trim(Me.Row2.Value) = "" Then
Me.Row2.SetFocus
MsgBox "Please enter a Value"
Exit Sub
End If
I have been trying to create a similar things but to display a message box if the data entered into the textbox is 'text or space' and not a number.
It doesnt work and triggers the message box whether i enter a number or text or a space.
Any help would be much appreciated.
VBA Code:
If Application.WorksheetFunction.IsText(Trim(Me.Row2.Value)) Then
Me.Row2.SetFocus
MsgBox "This field should contain numbers only!" & vbNewLine & vbNewLine & "Please check that no text or a 'space' has been entered into this field", 64, "RECOVERY FIELD ERROR!"
Exit Sub
End If