1. How do I correct a VBA "Compile Error

Anonymous
2018-07-16T17:51:36+00:00

Hello Community

I am creating a VBA Project yet when I try to run it I get "Compile Error" message. How do I fix it ? I understand that the message is stating that Exel does not understand the command I am trying to Implement, but I have no Idea how to fix it.

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments
{count} votes

4 answers

Sort by: Most helpful
  1. Anonymous
    2018-07-16T18:00:33+00:00

    Can you copy the code to a message here?

    best wishes

    0 comments No comments
  2. Anonymous
    2018-07-16T18:24:49+00:00

    I am Copying both Code and the work sheet I am setting up. This sheet is to be activated within the entire workbook which consist of a number of pages.

    Code:

    Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)

    End Sub

    Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)

    If Not Intersect(Target, Range("D3:N11")) Is Nothing Then

        If Taget.Value = "Ð" Then

        Target.Value = "Ï"

        Exit Sub

        End If

        If Target.Value = "x" Then Target.Value = "Ð"

        If Target.Value = "Ï" Then Target.Value = "x"

        If Target.Value = Empty Then Target.Value = "Ð"

    End If

    End Sub

    ***Please note that "Ð" represents Unlock, "Ï" represents Lock, and "x" represent's "restricted"

    These commands are supposed to work on the double click, but nothing is working even with the first line of code. Upon testing, the "lock" symbol does not convert to "unlock" or "restricted". Nor does clicking any of the blank cells work on the double click.

    Any help you can give is greatly appreciated.

    User Admin Sheet 1 Sheet 2 Sheet 3 Sheet 4
    Jamie "Ð" "Ï" "x"

    Thanks, 

    JeanMarie

    0 comments No comments
  3. Anonymous
    2018-07-16T19:16:37+00:00

    I noticed a typo in your code:

      If Taget.Value = "Ð" Then

    You are missing a r in Target

      If Target.Value = "Ð" Then

    First question: have you put the code into the correct Worksheet module?

    A working file may be found in my Public folder of my OneDrive;

    I have changed all accented letters to unaccented, so "Ð" is coded as ""D", etc.

    Link is:

    https://1drv.ms/x/s!AkhpKJf_GSEWgfJ9OaOKGe4PlyFagg

    best wishes

    0 comments No comments
  4. Anonymous
    2018-07-16T20:05:55+00:00

    Try this. . . .

    Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)

        If Not Intersect(Target, Range("D3:N11")) Is Nothing Then

            If Target.Value = Chr(208) Then

                Target.Value = Chr(207)

                Exit Sub

               Cancel = True     'added this

            End If

            If Target.Value = "x" Then Target.Value = Chr(208)

            If Target.Value = Chr(207) Then Target.Value = "x"

            If Target.Value = Empty Then Target.Value = Chr(208)

        End If

        Cancel = True

    End Sub

    Gord

    0 comments No comments