以下是我的代码。基本上我想在另一个工作簿中找到一个单元格的行值(这里是“x”),匹配日期。代码正在运行,但它没有返回值。
Cells(2,10)
是一个日期(写为dic-13),Range("B8:J9")
的第一行是日期的Range
(“dic-11”,“dic-12” “,”dic-13“等......)
Sub BuscarDatos()
Dim y As Workbook
Dim x As Workbook
Set y = Application.ActiveWorkbook
Set x = Application.Workbooks.Open("G:\Estudios\Biblioteca\Mercado Accionario _
Chileno\InsertarEmpresa.xlsm")
y.Sheets("Información Financiera").Cells(Range("J3").Row, Range("J3").Column) = _
Application.HLookup(CLng(Cells(2, 10)), _
x.Sheets("Cencosud").Range("B8:J9"), 2, False)
End Sub
答案 0 :(得分:1)
试试这个
Sub BuscarDatos()
Dim y As Workbook
Dim x As Workbook
Set y = Application.ActiveWorkbook
Set x = Application.Workbooks.Open("G:\Estudios\Biblioteca\Mercado Accionario Chileno\InsertarEmpresa.xlsm")
'modified line
y.Sheets("Información Financiera").Cells(Range("J3").Row, Range("J3").Column) = Application.HLookup(y.Sheets("Información Financiera").Cells(2, 10), x.Sheets("Cencosud").Range("B8:J9"), 2, False) 'modified line
End Sub