我想写一个 Vlookup 语句
I want to write to a Vlookup statement
我想写一个 Vlookup 语句。我用一系列的 VBA 形式填充文本框:
使用frmDragonInfo
.txtInfo6 = Application.Text(WorksheetFunction.VLookup(DrLevel + 1, Range(DrCode), 2), "[hh]:mm")
然后,更新文本框后,我想单击表单上的 cmd 按钮再次写回:
有床单("DataList")
Application.WorksheetFunction.VLookup(DrLevel, Range(DrCode), 2) = txtInfo1.Text
DrLevel 是一个从 1 到 100 的数字,DrCode 是 'DataList'sheet 上的一个命名范围。
那是行不通的。我可以写一个 Vlookup 吗?如果是这样,如何?谢谢
Dim f As Range
Set f = Sheets("DataList").Range(DrCode).find(DrLevel, lookat:=xlWhole)
If Not f Is Nothing Then
f.Offset(0,1).Value = txtInfo1.Text
End If
您不必依赖工作表函数来处理所有事情。 VBA 有自己的 Application.Text
版本。
.txtInfo6 = Format(WorksheetFunction.VLookup(DrLevel + 1, Range(DrCode), 2), "[hh]:mm")
是否应该将(可选)range_lookup 参数设置为 False 以获得完全匹配? (VLOOKUP function)
使用.Columns(1)
切掉Range(DrCode)
的第一列并向后看。
dim rw as long
rw = application.match(DrLevel + 1, Range(DrCode).Columns(1), 0)
Range(DrCode).cells(rw, 2) = txtInfo1.Text
我想写一个 Vlookup 语句。我用一系列的 VBA 形式填充文本框:
使用frmDragonInfo
.txtInfo6 = Application.Text(WorksheetFunction.VLookup(DrLevel + 1, Range(DrCode), 2), "[hh]:mm")
然后,更新文本框后,我想单击表单上的 cmd 按钮再次写回:
有床单("DataList")
Application.WorksheetFunction.VLookup(DrLevel, Range(DrCode), 2) = txtInfo1.Text
DrLevel 是一个从 1 到 100 的数字,DrCode 是 'DataList'sheet 上的一个命名范围。 那是行不通的。我可以写一个 Vlookup 吗?如果是这样,如何?谢谢
Dim f As Range
Set f = Sheets("DataList").Range(DrCode).find(DrLevel, lookat:=xlWhole)
If Not f Is Nothing Then
f.Offset(0,1).Value = txtInfo1.Text
End If
您不必依赖工作表函数来处理所有事情。 VBA 有自己的 Application.Text
版本。
.txtInfo6 = Format(WorksheetFunction.VLookup(DrLevel + 1, Range(DrCode), 2), "[hh]:mm")
是否应该将(可选)range_lookup 参数设置为 False 以获得完全匹配? (VLOOKUP function)
使用.Columns(1)
切掉Range(DrCode)
的第一列并向后看。
dim rw as long
rw = application.match(DrLevel + 1, Range(DrCode).Columns(1), 0)
Range(DrCode).cells(rw, 2) = txtInfo1.Text