我想使用HLookUp Function
,但范围来自另一个工作表,我无法正确使用它。
Sub P()
Dim mes As String
Dim i As Integer
Dim valor As Double
Dim bobes As Range
bobes = Worksheets("Cash Cost EP").Range("C3:S10")
i = 4
Do Until Cells(2, i) = ""
mes = Cells(2, i)
mes = Right(Cells(2, i), 2)
If mes = "01" Then
mes = "Enero"
ElseIf mes = "02" Then
mes = "Febrero"
ElseIf mes = "03" Then
mes = "Marzo"
ElseIf mes = "04" Then
mes = "Abril"
ElseIf mes = "05" Then
mes = "Mayo"
ElseIf mes = "06" Then
mes = "Junio"
ElseIf mes = "07" Then
mes = "Julio"
ElseIf mes = "08" Then
mes = "Agosto"
ElseIf mes = "09" Then
mes = "Setiembre"
ElseIf mes = "10" Then
mes = "Octubre"
ElseIf mes = "11" Then
mes = "Noviembre"
ElseIf mes = "12" Then
mes = Diciembre
End If
Sheets("resumen").Range("d17").Value = "= HLookup(mes, bobes, 3, 0)"
i = i + 1
Loop
End Sub
当我运行代码时,它不能按照我想要的方式工作。
请帮助,我想在单元格D17
中获取Hlookup
的值。
发布于 2014-03-18 12:20:22
这有点不清楚,因为“没有以我想要的方式工作”对问题是什么有点含糊。我猜您需要将下面的代码行更改为:
Sheets("resumen").Range("d17").Value = "=HLOOKUP(" & Chr(34) & mes & Chr(34) _ & ",'" & bobes.Parent.Name & "'!" & bobes.Address & ",3,0)"
以便将mes
的值(包括双引号)而不是文本‘me’传递给函数,并标识bobes
范围的工作表和范围地址。
https://stackoverflow.com/questions/22468037
复制相似问题