Refresh cmd button on User Form thinks I'm skipping data, resulting in error.

Livin404

Well-known Member
Joined
Jan 7, 2019
Messages
743
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Good evening, I have a macro for a UserForm where data is placed into a data entry form which is then placed into a database which is fed into my Pivot Table. It works great except for one small part. It will not allow me to simply use my refresh command button, because it thinks I am skipping or leaving blank a required block. I need the code tweaked so it will not apply if only the refresh command is used. Sometimes I need my tables refreshed without necessarily putting data in.

The code below is what I'm using to make sure the block is not skipped. Yet when I select refresh it thinks I'm leaving the date block empty. Any suggestions? I want to keep my refresh command button on the UserForm. I'm trying to keep the user activity limited to just one worksheet.

VBA Code:
Private Sub TxtDate_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If Trim(TxtDate.Value) = "" And Me.Visible Then
MsgBox "Please enter date in dd mmm yy format.", vbCritical, "Error"
Cancel = True
InboundForm.TxtDate.SetFocus
TxtDate.BackColor = vbYellow
Else
TxtDate.BackColor = vbWhite
End If
End Sub

Thank you,
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.

Forum statistics

Threads
1,214,790
Messages
6,121,608
Members
449,038
Latest member
apwr

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