0

I am working on a project where I am importing sheets from other files with the same setup. I have some code written in the worksheet module, which is expected to come with the import. I am facing an error when dealing with files placed in a shared drive. The worksheet code is being replaced automatically with the following, which is causing my file to crash.

    MultiUse = -1 'True
    End

Any idea why this is happening and how can it be solved?

In addition, this is my worksheet module code.

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

Dim BackDoor As Boolean

BackDoor = Worksheets("Info").Cells(8, 5).Value

If BackDoor = False Then
    
    If ActiveCell.Locked Then
        Cancel = True
    End If
    
End If

End Sub

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

Dim BackDoor As Boolean

BackDoor = Worksheets("Info").Cells(8, 5).Value

If BackDoor = False Then
    Cancel = True
End If

End Sub

This is the code I am using for importing. impSHT is the sheet I am copying for the other workbook.

   If numSheets = 0 Then
            impSHT.Copy After:=SHT
   Else
       Set LastSHT = ThisWorkbook.Worksheets(SHT.Cells(RefRow + numSheets, RefCol).Text)
       impSHT.Copy After:=LastSHT
   End If
Omar Adel
  • 1
  • 2
  • 2
    That looks like part of the header from an exported VBA module. Possibly your destination or source file is corrupted: typically copying a sheet with embedded code is not problem. https://www.vitoshacademy.com/vba-attributes-the-high-end-in-vba/ – Tim Williams Apr 21 '21 at 20:07
  • That code cannot just show up by copying a worksheet, it had to come from **importing** an exported document class module from the file system. Sounds like there's more to this story. – Mathieu Guindon Apr 21 '21 at 20:13

0 Answers0