Stopping the save button from clearing textboxes on UserForm.

bandito04

New Member
Joined
Feb 17, 2023
Messages
3
Office Version
  1. 2016
Platform
  1. Windows
Hello,

I'm looking for assistance with my userform. I am utilizing a shared workbook as a department dashboard. The macros are working as intended with the exception of my save button.

Issue:
Save button does in fact save the workbook with:

Private Sub CommandButton5_Click()
ThisWorkbook.Save
MsgBox "Log Entry Saved"
End Sub

However, with the workbook being shared, should another user add an entry, when the save button is clicked the conflicting changes pop-up displays. My idea is to have the user "Accept all other changes" which will then update their instance and allow them to resave their changes. However, when "Accept all other changes" is clicked and the workbook updates (saves) all textboxes on the UserForm are cleared forcing my user to reenter all data which can be pretty lengthy.

Is there a method I can utilize to prevent the save command button from clearing all fields. I have a Clear commandbutton set up to replace that function.

Thank you.
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Hi bandito04,

One possible solution would be to use the Worksheet_Change event to capture any changes made to the worksheet and then programmatically update the form with the new values without the user manually entering them. You could also use the BeforeSave event to detect changes to the worksheet and then programmatically update the form with the new values. Finally, you could use the Workbook_BeforeSave event to check if there are any conflicting changes and prompt the user to accept/reject them before saving the workbook. If they accept the changes, you can then programmatically update the form with the new values.
 
Upvote 0
Hi bandito04,

One possible solution would be to use the Worksheet_Change event to capture any changes made to the worksheet and then programmatically update the form with the new values without the user manually entering them. You could also use the BeforeSave event to detect changes to the worksheet and then programmatically update the form with the new values. Finally, you could use the Workbook_BeforeSave event to check if there are any conflicting changes and prompt the user to accept/reject them before saving the workbook. If they accept the changes, you can then programmatically update the form with the new values.
Thank you for this!

Ultimately found that i had written in the code to =" " for each value after i hit the save button. So i was my own meance.

I can definitely use these events you listed for other aspects of my workbook so i do appreciate your reply!!
 
Upvote 0

Forum statistics

Threads
1,223,909
Messages
6,175,314
Members
452,634
Latest member
cpostell

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