In Excel VBA we have a spreadsheet which stores information and have one of each of our sites. The workbooks are identical but each contains info for a specific sites. These are in constant use and we have too many users to use a single book.
Since an update to office 365, if a user has more than one sheet open then the scripts are writing the data to the wrong sheet. The scripts are contained in a module and it appears that excel, on rare occasions runs the script (of the same name) from the wrong workbook. Is there a simple way to make the code only run in the workbook it is contained in? One thought was if we put it in the "this workbook" container rather than in a module might have this effect.
The spreadsheet is very long but in essence this is what it does:
Private Sub cmdSave_Click()
Set ws = Sheets("Repairs Log")
lr = ws.Cells(Rows.Count, 1).End(xlUp).Row + 1
ws.Cells(lr, 3).Value = txtsite
ws.Cells(lr, 4).Value = lbxblock
ws.Cells(lr, 5).Value = txtflat
ws.Cells(lr, 6).Value = txtroom
ws.Cells(lr, 7).Value = txtdescription
ws.Cells(lr, 9).Value = lbxtype
ws.Cells(lr, 8).Value = lbxassigned.Text
End Sub
Any ideas