Hello,
I am trying to write a module that runs when a new page is created. I want it add a sub that activates before you double click a cell. This is the code that I have wrote so far. It does not let me run it because of a syntax error.
This line:
It gives me the error becuase of the quotation marks I'm using for "M4:AF23". The problem is that I need them to be in the code, so it reads the range correctly. Is there a way to fix this issue??
Thank you for your time.
I am trying to write a module that runs when a new page is created. I want it add a sub that activates before you double click a cell. This is the code that I have wrote so far. It does not let me run it because of a syntax error.
Code:
Sub AddCodeForRange()
With ThisWorkbook.VBProject.VBComponents(ActiveSheet.CodeName).CodeModule
N = .CountOfLines
.InsertLines N + 1, "Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)"
.InsertLines N + 2, vbNewLine
.InsertLines N + 3, vbTab & "If Not Application.Intersect(Target, Range("M4:AF23")) Is Nothing Then"
.InsertLines N + 4, vbTab & vbTab & "Cancel = True"
.InsertLines N + 5, vbTab & vbTab & "InputFrm.Show"
.InsertLines N + 6, vbTab & "End If"
.InsertLines N + 7, vbNewLine
.InsertLines N + 8, "End Sub"
End With
End Sub
This line:
Code:
.InsertLines N + 3, vbTab & "If Not Application.Intersect(Target, Range("M4:AF23")) Is Nothing Then"
It gives me the error becuase of the quotation marks I'm using for "M4:AF23". The problem is that I need them to be in the code, so it reads the range correctly. Is there a way to fix this issue??
Thank you for your time.