【发布时间】:2016-01-23 14:23:35
【问题描述】:
我收到If first_unit = "N/A" Then 行的类型不匹配错误。我正在尝试根据另一个下拉菜单 (B10) 中的选择来更改下拉菜单 (B26:C26) 的文本。对于以下代码:
Dim check_change As Boolean
Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo 0
If check_change = False Then
If Target.Address = Range("B10").Address Then
Dim first_unit As Variant
Dim second_unit As Variant
Dim third_unit As Variant
check_change = True
first_unit = Application.WorksheetFunction.VLookup(Range("B10:E10"), Sheet3.Range("Jurisdictions_table"), 5, False)
second_unit = Application.WorksheetFunction.VLookup(Range("B10:E10"), Sheet3.Range("Jurisdictions_table"), 6, False)
third_unit = Application.WorksheetFunction.VLookup(Range("B10:E10"), Sheet3.Range("Jurisdictions_table"), 7, False)
Range("D5").Value = first_unit
Range("E5").Value = second_unit
Range("F5").Value = third_unit
If first_unit = "N/A" Then
Range("B26:C26").Value = "Certified"
End If
check_change = False
Exit Sub
End If
If Not Intersect(Target, Range("B19")) Is Nothing Then
check_change = True
Call ft_to_m(Range("D19"), Range("B19"))
check_change = False
Exit Sub
End If
If Not Intersect(Target, Range("D19")) Is Nothing Then
check_change = True
Call m_to_ft(Range("D19"), Range("B19"))
check_change = False
Exit Sub
End If
End If
End Sub
【问题讨论】:
-
N/A 或 #N/A ???
-
见stackoverflow.com/questions/17177709/…;注意
Application.WorksheetFunction.VLookup()和Application.VLookup()之间的区别
标签: excel vba variant mismatch