HLookup()与date:已经尝试CLng()
以下是我的代码。 基本上我想在另一个工作簿(这里是“x”)中find单元格的行值,并使用匹配的date。 代码正在运行,但不返回值。
Cells(2,10)
是一个date(写作为dic-13), Range("B8:J9")
的第一行是dateRange
(“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
尝试这个
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