click on a cell change the value of another cell

I can not achieve to do what looks like an easy process... I would like to give a value ("Hello") to a cell (named "ClInfo") in sheet named "Hardware" by a click on a cell (C47) in sheet named "1".

I tried this:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Selection.Count = 1 Then If Not Intersect(Target, Range("C47")) Is Nothing Then .range("ClInfo").value = "hello" End If
End If 

What should I do to make it works? Thanks for your help!

1 Answer

Your code could look like the following, it looks like you're just missing the Worksheet object:

Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Selection.Count = 1 Then If Not Intersect(Target, Range("C47")) Is Nothing Then Worksheets("Hardware").Range("ClInfo").Value = "hello" End If End If
End Sub

Make sure you're placing this as the VBA for your sheet named 1:

enter image description here

7

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like