我有一个将数据存储在不同工作表中的ERP系统,现在我想创建一个宏,要求您键入一个ID号,并使用该输入来查找输入值与该ID匹配的行数。具有所有数据的归档文件已经为每一行生成了一个ID号。
我不知道如何解决此问题,因为我对VBA和程序设计还很陌生(到目前为止已经有3天了)
编辑:我可能还需要为inputValue添加一个If语句,该语句与列表中的任何ID号都不匹配
Sub PullBackUp()
inputvalue = Application.InputBox("Type ID number", "Pull a delivery-note back up", Type:=1)
If inputvalue = vbNullString Then
MsgBox "Please type an ID number to proceed"
Else
'Locate the row with the ID number from the inputValue
End If
End Sub
我希望使用通过inputValue
获得的ID号获得将数据放入其中的整行
答案 0 :(得分:0)
想象你的专栏是B
:
Range("B1").End(xlDown).Find(What:=inputValue, After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Activate
供您参考:我转到“开发人员”菜单项,并在第B
列中执行搜索时记录了一个宏。
答案 1 :(得分:0)
假设ID是唯一的,并且在A:A列中,您可以将其放在Else子句中:
idRow = columns("A:A").find(what:=InputValue).row