I am building a complex workbook in Excel and trying make it as user friendly as possible.
Example:
I have table call Tbltst that has three columns Control #, Dollars, and Returned.
Control # is auto populated, Dollars is user entered and Returned is a Validation drop-down.
When I change the Value from N to Y in Returned I want all the amounts in the Dollars column to change to 0 for that Control# and the other entries Returned to change to Match.
So say I change the first 1234 in the list. That $50 dollars should be blanked and Rows 3 and 6 Dollars should be blanked also and their returned column Updated to Y to match row 1.
The workbook is locked and Control# is not editable (formula driven as mentioned above) but both Dollars and Returned are editable.
I did try using formulas but to set a cell based on what is above requires a macro.
User's input in Returned
column tirggers Worksheet_Change
to update the data.
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rngTab As Range
Set rngTab = ActiveSheet.Range("Tbltst")
If Not Intersect(Target, rngTab) Is Nothing Then
With Target
If .CountLarge = 1 And .Cells(1).Column = 3 Then
If UCase(.Value) = "Y" Then
Dim sKey, c
sKey = Cells(.Row, 1)
Application.EnableEvents = False
For Each c In rngTab.Columns(1).Cells
If c.Value = sKey Then
Cells(c.Row, 2) = 0
Cells(c.Row, 3) = "Y"
End If
Next
Application.EnableEvents = True
End If
End If
End With
End If
End Sub