-
find if cell value changed
Hi,
I am having an Excel where the users need to fill in all the details in a row from column 4 to 8. so the values on column 5 depends on column 4 and value on column 6 depends on column 5 and henceforth..
I need to detect if later the user changed the value in column 4 then I need to clear all the values on columns 5,6,7,8 for that row.
Please advice how this is possible.
Thanks,
Mahesh
-
I think this will do what you want:[vba]Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Columns(4)) Is Nothing Then Exit Sub
Target.Offset(, 1).Resize(, 4).ClearContents
End Sub[/vba]
-
[VBA]
'Save changed rows
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 4 Then
Sheets(2).Cells(Rows.Count, 1).End(xlUp).Offset(1) = Target.Row
End If
End Sub
'Remove changes
Sub Reset()
On Error GoTo Exits
Application.EnableEvents = False
With Sheets(2)
Dim cel As Range
For Each cel In .Range(.Cells(1, 1), .Cells(1, 1).End(xlDown))
Sheets(1).Cells(cel, 5).Resize(, 4).ClearContents
cel.ClearContents
Next
End With
Exits:
Application.EnableEvents = True
End Sub
[/VBA]
MVP (Excel 2008-2010)
Post a workbook with sample data and layout if you want a quicker solution.
To help indent your macros try Smart Indent
Please remember to mark threads 'Solved'
-
thanks for the code...
then how the Reset() function is called?
-
Put a button on the sheet next to where the data is written and assign it to the macro. When you see recorded changes and wish to clear it, then click the button.
MVP (Excel 2008-2010)
Post a workbook with sample data and layout if you want a quicker solution.
To help indent your macros try Smart Indent
Please remember to mark threads 'Solved'
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules