I am facing a complication with excel macro syntax. My workbook contains several sheets, with the first one titled "Reference Sheet". There are some entries in the other sheets that I do not want the user to edit through the sheet they are currently working on but only through the Reference Sheet.
I locked the cells and used protect sheet, however I want the user to receive a prompt message whenever they double click on one of the cells in the concerned range, asking them if they want to change the selected cell but in the Reference Sheet.
My aim is to have the same cell selected in the current sheet, selected in the Reference Sheet to be able to edit it.
I posted the following code in the corresponding sheet VB but apparently there is an error in the Cells property at the end -> Cells(val1, val2).Select
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Intersect(Target, Range("C2:C5,E2")) Is Nothing Then
Else
Dim Msg As String, Title As String
Dim Config As Integer, Ans As Integer
Msg = "Do not modify this entry from the current sheet."
Msg = Msg & vbNewLine
Msg = Msg & "This modification is only enabled in the Reference Sheet."
Msg = Msg & vbNewLine
Msg = Msg & "Would you like to go to the corresponding cell and modify it?"
Title = "Attention"
Config = vbYesNo + vbExclamation
Ans = MsgBox(Msg, Config, Title)
If Ans = vbYes Then
Dim val1 As Integer, val2 As Integer
val1 = ActiveCell.Row
val2 = ActiveCell.Column
Worksheets("Reference Sheet").Activate
Cells(val1, val2).Select
End If
End If
End Sub
Your thoughts are much appreciated.