I have an issue with activating a sheet from a user form, the same code works fine in Excel 2003 to Excel 2010, doesn't work with Excel 2013.
This is how to simply reproduce the issue:
Have a workbook with 2 worksheets in it, called Sheet1 and Sheet2 let's say, and on Sheet1 2 buttons:
On click of
Button1activatesSheet2worksheet using aMacro1with 1 line in it:ThisWorkbook.Sheets("Sheet2").Selectand I can edit data from it fine.
On click of
Button2aUserForm1pops up and on click ofCommandButton1call same Macro1 like this:Unload Me Macro1the
Sheet2worksheet is activated, sort of, but if I edit data in it, it actually updates corresponding cells in Sheet1, if I click onSheet1I can see data entered in there!
Clicking back to Sheet2 worksheet activates the Sheet2 sheet properly.
Has anyone seen such behaviour? If yes, are there any coding workarounds to properly activate Sheet2?
application.screenupdating = falseat this time. Also you MUST call the userform like thisuserform.show False. check the sheet name, and be sure to haveon error goto 0. - Patrick Lepelletier