[英]Excel 1004 error vlookup
i have this line: 我有这条线:
LArticol.Caption = Application.WorksheetFunction.VLookup(Serie.Value,[TEST], 2, 0)
And my error is Run-time error 1004 I've try with 我的错误是我尝试使用的运行时错误1004
LArticol.Caption = Application.WorksheetFunction.VLookup(Serie.Value,ThisWorkbook.Sheets("ELECTRICE").Range("TEST"), 2, 0)
but...same thing i really need help 但是...我确实需要帮助
CODE: 码:
Private Sub Serie_Change()
LArticol.Caption = Application.WorksheetFunction.VLookup(Serie.Value,ThisWorkbook.Sheets("ELECTRICE").Range("TEST"), 2, 0) End Sub
Private Sub UserForm_Initialize()
Call Serii
End Sub
Serii module Serii模块
Sub Serii()
Dim Ssheet As Worksheet
Set Ssheet =
ThisWorkbook.Sheets("ELECTRICE")
If Ssheet.Cells(Rows.Count, 1).End(xlUp).Row = 1 Then
sslr = 3 Else
sslr = Ssheet.Cells(Rows.Count, 1).End(xlUp).Row
End If
For X = 3 To sslr
UserForm1.Serie.AddItem Ssheet.Cells(X, 1)
Next X
End Sub
Is ELECTRICE
the active sheet? ELECTRICE
是活动表吗? Application.WorksheetFunction.VLookup
operates on the active sheet unless you tell it otherwise. 除非另行说明,否则
Application.WorksheetFunction.VLookup
将在活动工作表上运行。
Also, 也,
ThisWorkbook.Sheets("ELECTRICE").Range("TEST")
will return $A$3:$H$1048576
. 将返回
$A$3:$H$1048576
。 If you want it to return ELECTRICE!$A$3:$H$1048576
then you should use 如果您希望它返回
ELECTRICE!$A$3:$H$1048576
,则应使用
ThisWorkbook.Names("TEST").RefersTo
Keep in mind too that this requires the named range's scope to be defined as Workbook
and not a specific sheet. 还要记住,这要求将命名范围的范围定义为
Workbook
而不是特定的工作表。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.