Try:
Option Explicit
' This code goes in the Workbook Class Module
'Hello I have very recently just started coding VBA. I am currently trying to make it
'so I can link two cells from different sheets together, so they will always be the
'same and update no matter which I edit. Specifically trying to get Cell A11 on sheet 1
'to link with Cell B18 on sheet 2. I have code that works on the same page, however I
'cannot get it to work across sheets. The code I am currently using looks like this:
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
Dim sh1 As Worksheet, sh2 As Worksheet
Set sh1 = Sheet1: Set sh2 = Sheet2
If Target.Count > 1 Then Exit Sub
Application.EnableEvents = False
If Sh.Name = sh1.Name And Target.Address = "$A$11" Then
sh2.Range("$B$18") = sh1.Range("$A$11").Value
ElseIf Sh.Name = sh2.Name And Target.Address = "$B$18" Then
sh1.Range("$A$11") = sh2.Range("$B$18")
End If
Application.EnableEvents = True
End Sub
Bookmarks