Unlock cells based on found value

Greasy

Board Regular
Joined
Jan 25, 2013
Messages
55
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:

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.
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.

Forum statistics

Threads
1,196,501
Messages
6,015,563
Members
441,901
Latest member
joshtfin

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