VBA "user-defined type not defined"
VBA "user-defined type not defined"
我在这行代码中收到“未定义用户定义类型”错误
Sub Customer_Load()
这是我的代码
Option Explicit
Sub Customer_Load()
Dim CltRow As Long, LastRepRow As Lon, CustCol As Long
With Sheet1
If .Range("B6").Value = Empty Then
MsgBox "Por favor, seleccione un cliente"
Exit Sub
End If
CltRow = .Range("B6").Value
'Clear Existing Data
.Range("E4:G4,E6:G6,E8:G8,E10:G10,E12:G12,J4:L4, J6:L6,J8:L8,J10:L10,J12:L12").ClearContents 'Clear Customer Cells
.Range("D17:I45").ClearContents 'Clear All Other Fields
For CustCol = 1 To 12
.Range(Sheet2.Cells(1, CustCol).Value).Value = Sheet2.Cells(CltRow, CustCol).Value
Next CustCol
.Shapes("ExistCustGrp").Visible = msoCTrue
.Shapes("NewCustGrp").Visible = msoFalse
.Shapes("ExistRepGrp").Visible = msoCTrue
.Shapes("NewRepBtn").Visible = msoFalse
End With
End Sub
我看到修复此错误的方法是添加可用的参考,但这些是我仅有的可用参考。
你在第三行有一个语法错误(Long 不是 lon),lon 不存在:
Dim CltRow As Long, LastRepRow As Lon, CustCol As Long
Dim CltRow As Long, LastRepRow As Long, CustCol As Long
此外,我认为您不希望数据类型为“Long”。相反,你想要“行”。
我在这行代码中收到“未定义用户定义类型”错误
Sub Customer_Load()
这是我的代码
Option Explicit
Sub Customer_Load()
Dim CltRow As Long, LastRepRow As Lon, CustCol As Long
With Sheet1
If .Range("B6").Value = Empty Then
MsgBox "Por favor, seleccione un cliente"
Exit Sub
End If
CltRow = .Range("B6").Value
'Clear Existing Data
.Range("E4:G4,E6:G6,E8:G8,E10:G10,E12:G12,J4:L4, J6:L6,J8:L8,J10:L10,J12:L12").ClearContents 'Clear Customer Cells
.Range("D17:I45").ClearContents 'Clear All Other Fields
For CustCol = 1 To 12
.Range(Sheet2.Cells(1, CustCol).Value).Value = Sheet2.Cells(CltRow, CustCol).Value
Next CustCol
.Shapes("ExistCustGrp").Visible = msoCTrue
.Shapes("NewCustGrp").Visible = msoFalse
.Shapes("ExistRepGrp").Visible = msoCTrue
.Shapes("NewRepBtn").Visible = msoFalse
End With
End Sub
我看到修复此错误的方法是添加可用的参考,但这些是我仅有的可用参考。
你在第三行有一个语法错误(Long 不是 lon),lon 不存在:
Dim CltRow As Long, LastRepRow As Lon, CustCol As Long
Dim CltRow As Long, LastRepRow As Long, CustCol As Long
此外,我认为您不希望数据类型为“Long”。相反,你想要“行”。