Alright, I've got the multiple "+/-/=" cells working properly, as well as a "Date Entered" function working... *HOWEVER* I can't seem to figure out how to lock ALL these cells, except for the "Add to" and "Subtract from" cells! =\
I'm sure the bit of code that was posted first to auto-unlock and re-lock the cells before and after the code will work, but I'm not sure where exactly it belongs, now that there are multiple instances of the "+/-/=" cells, as
well as there being the "Date Entered" auto-populating cells.
Basically, when I try to just lock the cells in the Excel UI, setting them as protected and then locking the sheet, the code has an error, because it's trying to modify cells that are locked, obviously... But how do I work around this, so the "+/-" cells stay unlocked, but EVERYTHING ELSE can be locked, and still populated with:
What was entered in the "+" tab,
What was entered in the "-" tab, and
WHEN either tab was last modified.
Here's what the code looks like so far, lacking, obviously, the "unlocking/locking" code bits...
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Dim iRow As Integer, iColumn As Integer
Dim sName As String
sName = ActiveSheet.Name
If Not Intersect(Target, Range("B5:E19")) Is Nothing Then
Application.EnableEvents = False
Application.ScreenUpdating = False
iColumn = Target.Column
If iColumn = 2 Then
Range("B5").Value = Range("B5").Value + Range("B12").Value
Range("B12").Value = ""
ElseIf iColumn = 3 Then
Range("B5").Value = Range("B5").Value - Range("C12").Value
Range("C12").Value = ""
End If
iColumn = Target.Column
If iColumn = 2 Then
Range("B7").Value = Range("B7").Value + Range("B14").Value
Range("B14").Value = ""
ElseIf iColumn = 3 Then
Range("B7").Value = Range("B7").Value - Range("C14").Value
Range("C14").Value = ""
End If
iColumn = Target.Column
If iColumn = 2 Then
Range("B9").Value = Range("B9").Value + Range("B16").Value
Range("B16").Value = ""
ElseIf iColumn = 3 Then
Range("B9").Value = Range("B9").Value - Range("C16").Value
Range("C16").Value = ""
End If
iColumn = Target.Column
If iColumn = 4 Then
Range("C5").Value = Range("C5").Value + Range("D12").Value
Range("D12").Value = ""
ElseIf iColumn = 5 Then
Range("C5").Value = Range("C5").Value - Range("E12").Value
Range("E12").Value = ""
End If
iColumn = Target.Column
If iColumn = 4 Then
Range("C7").Value = Range("C7").Value + Range("D14").Value
Range("D14").Value = ""
ElseIf iColumn = 5 Then
Range("C7").Value = Range("C7").Value - Range("E14").Value
Range("E14").Value = ""
End If
iColumn = Target.Column
If iColumn = 4 Then
Range("C9").Value = Range("C9").Value + Range("D16").Value
Range("D16").Value = ""
ElseIf iColumn = 5 Then
Range("C9").Value = Range("C9").Value - Range("E16").Value
Range("E16").Value = ""
End If
End If
Application.ScreenUpdating = True
Application.EnableEvents = True
If Target.Address = "$B$12" Then
Target.Offset(-7, 2) = Date
End If
If Target.Address = "$B$14" Then
Target.Offset(-7, 2) = Date
End If
If Target.Address = "$B$16" Then
Target.Offset(-7, 2) = Date
End If
If Target.Address = "$C$16" Then
Target.Offset(-7, 1) = Date
End If
If Target.Address = "$C$14" Then
Target.Offset(-7, 1) = Date
End If
If Target.Address = "$C$12" Then
Target.Offset(-7, 1) = Date
End If
If Target.Address = "$D$12" Then
Target.Offset(-7, 0) = Date
End If
If Target.Address = "$D$14" Then
Target.Offset(-7, 0) = Date
End If
If Target.Address = "$D$16" Then
Target.Offset(-7, 0) = Date
End If
If Target.Address = "$E$12" Then
Target.Offset(-7, -1) = Date
End If
If Target.Address = "$E$14" Then
Target.Offset(-7, -1) = Date
End If
If Target.Address = "$E$16" Then
Target.Offset(-7, -1) = Date
End If
End Sub
Any help would be greatly appreciated, they're imaginining, here at work, that I'm some "Excel Guru" while you all understand already that I am "Mediocre" at
best.
Thanks again, in advance!
Bookmarks