I have a database that I am trying to fix up a bit. It has a login system that prompts for username and password when opened. Once a user logs in, the username is logged in a hidden sheet. Users then make entries to the database with their username. Each entry is about 13 columns wide, with one of the columns being the username.
Currently the sheet with the data entered is locked. The data is entered via a userform. I want to let users edit entries they themselves made. My idea for doing this would be something like this:
I'm not really sure what methods I need to use or the best way of going about this, I especially and primarily do not know how to make it find all of the instances of the username, rather than just one and stopping. I'm not familiar with loops unfortunately. I think I can make it work if I figure out how to use offset and how to unlock a cell, but I'm not sure how I would make it work for the whole sheet.
Any advice or tips?
Thank you very much in advance, everyone on this site has been incredibly helpful to me and I really appreciate all of the help.
Currently the sheet with the data entered is locked. The data is entered via a userform. I want to let users edit entries they themselves made. My idea for doing this would be something like this:
Code:
Sub UnlockCells()
Dim UserName As String
Dim ws As Worksheet
Dim LogWs As Worksheet
Dim Sort As Worksheet
'set worksheets here
'set UserName here
Sort.UnProtect
With Sort Sheet
'Find the current username in the database
UserName.Find
'based on the cell with the username, unlock the cells to the left and right of the username
Offset(0,-3), Offset(0,-1), Offset(0,1), Offset(0,2), Offset(0,3), Offset(0,4), Offset(0,5), Offset(0,6),_
Offset(0,7), Offset(0,8), Offset(0,9), Offset(0,10) Unlock?
'Until? Find Next? With Next?
Protect Sort Sheet
End with
End Sub
I'm not really sure what methods I need to use or the best way of going about this, I especially and primarily do not know how to make it find all of the instances of the username, rather than just one and stopping. I'm not familiar with loops unfortunately. I think I can make it work if I figure out how to use offset and how to unlock a cell, but I'm not sure how I would make it work for the whole sheet.
Any advice or tips?
Thank you very much in advance, everyone on this site has been incredibly helpful to me and I really appreciate all of the help.