MsgBox alert if a number hasn't changed in the userform textbox.

danbates

Active Member
Joined
Oct 8, 2017
Messages
377
Office Version
  1. 2016
Platform
  1. Windows
Hi,

I was wondering this was possible.

I have a userform which enters the last number in the textbox1 from my worksheet.

What I would like is if the operator hasn't changed the number in textbox1 and then clicks the send button a message box appears telling them exactly that.

Basically I don't want the userform to be able to send the same number twice.

I hope this makes sense and any help would be appreciated.

Kind Regards

Dan
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
If you put code like this in the userform code module, it should help.

Note that the .TakeFocus******* property of the command button should be true.

Code:
Dim TBChanged As Boolean

Private Sub CommandButton1_Click()
    If TBChanged Then
        MsgBox "user has changed the textbox value"
    Else
        MsgBox "textbox not changed"
    End If
    TBChanged = False
End Sub

Private Sub TextBox1_AfterUpdate()
    With TextBox1
        TBChanged = (.Tag <> .Text)
        .Tag = .Text
    End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,289
Members
452,631
Latest member
a_potato

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