excel - 如何使用输入值来定位包含相同值的单元格?
问题描述
我有一个将数据存储在不同工作表中的 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
我希望使用我获得的 ID 号来获取已放入数据的整行inputValue
解决方案
想象一下您的专栏是B
:
Range("B1").End(xlDown).Find(What:=inputValue, After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Activate
供您参考:我转到“开发人员”菜单项,并在执行搜索时录制了一个宏列B
。
推荐阅读
- eclipse - Eclipse:包资源管理器文件突出显示
- typescript - webpack typescript 生产构建失败
- performance - 在 Julia 中使用抽象类型字段还是使用具体类型 Union 的结构?
- google-bigquery - Google DataStudio on BigQuery Data,如何显示数组结构
- powershell - PowerShell 可以与 RDP 提示交互吗?
- ruby-on-rails - DiscussionsController#show 中的 ActionView::SyntaxErrorInTemplate
- xml - 如何从 ejabberd 数据包对象中获取数据?
- r - 如何使用具有NA值的顶点属性对igraph对象(图)进行子图化-R
- android - 有没有办法在我的 MainActivity 到达后完成所有其他活动?
- python - Python Graphframes:安装依赖项时遇到问题