Hey guys, so
I'm trying to set up some code such that cells are autoupdated based on changes in some other cells. I also want any further changes to wipe out the previous update.
In other words, I want values I place in a particular cell to be shifted to the left based on the value in another cell. But if I change the value later, I want the first value that the macro entered to be wiped. I have the data the macro uses in that row as well however, so that can't be wiped.
It's kinda odd to explain I know, but hopefully that makes sense.
My first thought was to define a variable using the target row and Range, but I can't quite figure out how to do that...
My next thought, displayed below, was to protect the cells I wanted and then unprotect them after I wiped the row.
Here's what I have so far,
seems like I have a syntax error in the protect lines as well.
If anyone can fix this, or knows a better way, any help would be greatly appreciated
Thanks in advance,
Mike
I'm trying to set up some code such that cells are autoupdated based on changes in some other cells. I also want any further changes to wipe out the previous update.
In other words, I want values I place in a particular cell to be shifted to the left based on the value in another cell. But if I change the value later, I want the first value that the macro entered to be wiped. I have the data the macro uses in that row as well however, so that can't be wiped.
It's kinda odd to explain I know, but hopefully that makes sense.
My first thought was to define a variable using the target row and Range, but I can't quite figure out how to do that...
My next thought, displayed below, was to protect the cells I wanted and then unprotect them after I wiped the row.
Here's what I have so far,
Code:
Private Sub worksheet_change(ByVal target As range)
If Not Intersect(target, range("c1:c1000")) Is Nothing Then
Dim tgt As Long
tgt = target.Row
Worksheets("sheet1").Protect Contents: ["a1:c1000"] = True
ActiveSheet.Row(tgt).Delete
Worksheets("sheet1").Protect Contents: ["a1:c1000"] = False
ActiveSheet.Cells(tgt, (Cells(tgt, 2) + 3)).Value = (Cells(tgt, 3))
End If
End Sub
seems like I have a syntax error in the protect lines as well.
If anyone can fix this, or knows a better way, any help would be greatly appreciated
Thanks in advance,
Mike