Reputation: 3
I think this should be a simple straight-forward issue, however i am very new to VB coding.
I would like to have the contents of A1 copied to B1, with B1 completely editable, however if any changes are made to A1, the contents are again copied over to B1. The following code copies the contents, however on any change, but I only want it activated if changes are made to A1.
Private Sub Worksheet_Change(ByVal Target As Range)
Range("A3").Formula = Range("A1").Formula
End Sub
Thank you for your help, Randy
Upvotes: 0
Views: 2128
Reputation: 93046
Here is a page about Events in in Excel cpearson.com/excel/Events.aspx
There is nothing like "cell_changed". The best you can get is "Worksheet_change", but this will be triggered every time something on the sheet changes. Of course you can check in case of this event if it was "A1" that has changed. But probably your function will have to check that very often.
Upvotes: 0
Reputation: 12497
You can use this code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("A1")) Is Nothing Then
Range("B1") = Range("A1")
End If
End Sub
Upvotes: 2