乔山办公网我们一直在努力
您的位置:乔山办公网 > excel表格制作 > Excel 怎么查看EXCEL中的宏代码-excel查找宏,excel怎么用宏做查询

Excel 怎么查看EXCEL中的宏代码-excel查找宏,excel怎么用宏做查询

作者:乔山办公网日期:

返回目录:excel表格制作




方法很多:快捷键ALT+F11
工具——宏——VB编辑器
鼠标右键点sheet名——查看代码

代码一般写在模块里,有时候也会写在表里
可以复制
您也可以向我们团队发出请求,会有更专业的人来为您解答!
如果我的回答没能帮助您,请继续追问。



因为你没给出你的表结构,那么你可以根据我的假设的表结构自己修改,假设表结构如下,表2名为sheet2,表3名为sheet3,表4名为sheet4。三个表的A列均为编号列。我这里没有创建一个独立的文本框用作输入要e68a84e799bee5baa6e997aee7ad94361查询的文本,而是直接调用inputbox输入框。
vba代码如下:
Sub RngFind()
Dim StrFind As String
Dim Rng As Range
StrFind = InputBox("请输入要查找的值:")
If Trim(StrFind) <> "" Then
With Sheet2.Range("A:A")
Set Rng = .Find(What:=StrFind, After:=.Cells(.Cells.Count), LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False)
End With
With Sheet3.Range("A:A")
Set Rng2 = .Find(What:=StrFind, After:=.Cells(.Cells.Count), LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False)
End With
With Sheet4.Range("A:A")
Set Rng3 = .Find(What:=StrFind, After:=.Cells(.Cells.Count), LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False)
End With
If Not Rng Is Nothing Then
Application.Goto Rng, True
Sheet5.Cells(1, 1) = Rng
ElseIf Not Rng2 Is Nothing Then
Application.Goto Rng2, True
Sheet5.Cells(1, 1) = Rng
ElseIf Not Rng3 Is Nothing Then
Application.Goto Rng3, True
Sheet5.Cells(1, 1) = Rng
Else
MsgBox "没有找到符合的单元格!"
End If
End If
End Sub

相关阅读

关键词不能为空
极力推荐

ppt怎么做_excel表格制作_office365_word文档_365办公网