[英]vlookup but the name of the cell that will return not the value in the cell
just like to ask if you know a formula like in the vlookup style but the cell name that it will return not the value of the cell? 就像问您是否知道vlookup样式中的公式一样,但是它返回的单元格名称不是该单元格的值? thanks!
谢谢!
I want to put the value of sal
in the Application.WorksheetFunction.VLookup(name, Sheet2.Range("Table6"), 5, False)
but in this function the value inside the cell will return not the name of the cell 我想将
sal
的值放在Application.WorksheetFunction.VLookup(name, Sheet2.Range("Table6"), 5, False)
但是在此函数中,单元格内的值将不返回单元格的名称
Sub purchase()
Dim name As String
name = ActiveSheet.Range("C3")
sal = Application.WorksheetFunction.VLookup(name, Sheet2.Range("Table6"), 5, False) - ActiveSheet.Range("d3").Value
MsgBox " remaining: " & sal
End Sub
VLookup
only returns a value. VLookup
仅返回一个值。 You will need the match
function. 您将需要
match
功能。 This will return the row number which you can use to access the desired cells. 这将返回可用于访问所需单元格的行号。
Sub purchase()
Dim Name As String
Name = ActiveSheet.Range("C3")
Dim MatchedRow As Long
MatchedRow = Application.WorksheetFunction.Match(Name, Sheet2.Range("Table6").Columns(1), 0)
'Find the row number (relative to the range table6) of the found name
Dim Sal As Double
Sal = Sheet2.Range("Table6").Cells(MatchedRow, 5).Value - ActiveSheet.Range("D3").Value
Sheet2.Range("Table6").Cells(MatchedRow, 5).Value = Sal
'Write the calculated Sal back
MsgBox " remaining: " & Sal
End Sub
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.