在另一台计算机上运行宏时,出现编译器错误。 在我的笔记本电脑上工作正常。
这是错误:
“隐藏模块中的编译错误:Sheet2通常会发生此错误 当代码与版本,平台或体系结构不兼容时 该应用程序。单击“帮助”以获取>>有关如何 更正此错误”
这是我在模块内部的代码:
Sub NextButton()
'Remove OHR ID len than 9 digi
Worksheets("OHR ID for Enrollment").Activate
lr = Range("A" & Rows.Count).End(xlUp).Row
For i = 2 To lr
If Len(Cells(i, 1)) < 9 And Len(Cells(i, 1)) > 0 Then
MsgBox "Invalid OHR in Cell: " & Cells(i, 1).Address
Cells(i, 1).Activate
Exit Sub
End If
Next i
'Remove Duplicate and and unhide sheet
Worksheets("OHR ID for Enrollment").Activate
If WorksheetFunction.CountA(Range("A2:A1048576")) = 0 Then
MsgBox "Please assign OHR ID for PKT"
Else
Worksheets("OHR ID for Enrollment").Unprotect "pkt19"
Columns("A:A").Select
Application.CutCopyMode = False
ActiveSheet.Range("A:A").RemoveDuplicates Columns:=1, Header:=xlYes
Selection.End(xlUp).Select
Worksheets("OHR ID for Enrollment").Range("B:B").Select
Selection.Locked = True
Range("A:A").Select
Selection.Locked = False
Worksheets("OHR ID for Enrollment").Protect "pkt19"
Cells(1, 1).Select
Worksheets("Question Paper").Visible = True
Worksheets("Question Paper").Activate
End If
End Sub