Forum Discussion
Divide numbers in 2 different cells and give the answer automatically in a third cell using VBA
TimothySmith Don't know why you would need to give them the PW to unlock the sheet. You set the cells they need to 'touch' as unlocked and then all the formula cells get locked. If they have a problem they will have to have you fix it (which would be the same if there is a problem with the VBA).
If you still insist on VBA then add a _change routine onto the VBA sheet you want to automatically update. So in VBA (Alt-F11) you need to double click the sheet icon to open the macro page:
Then paste something like this:
Private Sub Worksheet_Change(ByVal Target As Range)
With Me
.Range("D16").Value2 = .Range("D7") / .Range("D13")
End With
End Sub
you could get fancy and check what was updated and only make the change if one of the input cell changed and you could also do warnings or something if they try to enter a value into D16 ... But based on your request this is the 'answer' even though I still think locking the sheet is a much better solution. Just right click on cell D7, select Format Cells, go to the Protection tab and unclick 'Locked'. Repeat with D13 and any other cells/ranges you want them to actually enter data into. Then lock the sheet and you can even select options if you want them to be able to select those locked cell (but not change) or not even select, etc...
Either way, good luck.
- TimothySmithJan 12, 2022Copper ContributorThank you mtarler, I really do appreciate the help and may wind up doing what you suggested with protecting the cells.
Thanks again, you are appreciated