I have several UserForms in my Excel workbook. After running one of them, I have noticed some very strange behavior. I have seen others post about it on a different site, but the solution offered to them doesn't seem like the right solution for me.
Here's what is happening, in a nutshell:
- The user clicks a button on a page called "Purchase Order Log" that activates a UserForm. The Initialize code runs and fills in some text boxes with information if certain conditions are met. If they are not, the text boxes are left blank.
- When the user is finished entering information into the text boxes, they click a button called "Save & Close". Code is then executed to write the information in the text boxes to a sheet called "PO Info".
- A message box appears on the screen telling the user their information has been saved.
- The UserForm is unloaded.
- The sheet "Purchase Order Log" is then Activated.
AFTER all of this happens, the user types something into a cell on "Purchase Order Log." However, while it appears on the screen that they are doing this, the data they have typed ACTUALLY ends up going onto the "PO Info" sheet. (Side note: the scroll wheel on the mouse does not work at this time. It is only after switching to another sheet that the scroll wheel functions again.)
One solution that was offered on a thread about the same problem was to make the UserForm show "vbModeless". However, in my case, I do not want the user to be able to make changes to the sheets while the UserForm is visible, so this does not seem like the correct solution for me.
Here's the code that runs when the user presses the "Save & Close" button on the UserForm, in case it is helpful.
Can anyone suggest another way to fix this rather strange problem? I can't understand why the heck Excel would appear to allow the user to type in information to one sheet while it's actually being input into another!
Here's what is happening, in a nutshell:
- The user clicks a button on a page called "Purchase Order Log" that activates a UserForm. The Initialize code runs and fills in some text boxes with information if certain conditions are met. If they are not, the text boxes are left blank.
- When the user is finished entering information into the text boxes, they click a button called "Save & Close". Code is then executed to write the information in the text boxes to a sheet called "PO Info".
- A message box appears on the screen telling the user their information has been saved.
- The UserForm is unloaded.
- The sheet "Purchase Order Log" is then Activated.
AFTER all of this happens, the user types something into a cell on "Purchase Order Log." However, while it appears on the screen that they are doing this, the data they have typed ACTUALLY ends up going onto the "PO Info" sheet. (Side note: the scroll wheel on the mouse does not work at this time. It is only after switching to another sheet that the scroll wheel functions again.)
One solution that was offered on a thread about the same problem was to make the UserForm show "vbModeless". However, in my case, I do not want the user to be able to make changes to the sheets while the UserForm is visible, so this does not seem like the correct solution for me.
Here's the code that runs when the user presses the "Save & Close" button on the UserForm, in case it is helpful.
Code:
Private Sub SaveAndCloseButton_Click()
SaveInfoToPOInfoSheet
MsgBox "Information has been saved!"
Unload Me
Sheets("Purchase Order Log").Activate
End Sub
Can anyone suggest another way to fix this rather strange problem? I can't understand why the heck Excel would appear to allow the user to type in information to one sheet while it's actually being input into another!