vba - Outlook VBA VLOOKUP 转换为 Excel 文件
问题描述
Outlook VBA 的新手如果我希望 Outlook 在 Excel 文件的 A 列中查找值并返回 B 列值,我有哪些选择?(与 VLOOKUP 相同)
Option Explicit
Sub LookUpExcel()
Dim objExcel As New Excel.Application
Dim exWb As Excel.Workbook
Dim ExcelFileName As String
Dim ColumnA As String
Dim ColumnB As String
Dim oMsg As MailItem
ExcelFileName = "C:\Users\vfdme\Desktop\test.xlsx"
Set exWb = objExcel.Workbooks.Open(ExcelFileName)
ColumnA = InputBox("Please Column A value.")
'[VLOOKUP / Search function?]
MsgBox (ColumnB)
ExitRoutine:
Set oMsg = Nothing
Set exWb = Nothing
Set objExcel = Nothing
End Sub
解决方案
让代码正常工作:) 感谢@braX 的提示。
Sub LookUpExcel()
Dim objExcel As New Excel.Application
Dim exWb As Excel.Workbook
Dim ExcelFileName As String
Dim ColumnA As String
Dim ColumnB As String
Dim oMsg As MailItem
ExcelFileName = "C:\Filelocation\Testfile.xlsx"
Set exWb = objExcel.Workbooks.Add(ExcelFileName)
ColumnA = InputBox("Please Column A value.")
ColumnB = exWb.Worksheets("Sheet1").Range("A:A").Find(ColumnA).Offset(0, 1).Value
msgbox (ColumnB)
ExitRoutine:
Set oMsg = Nothing
Set exWb = Nothing
Set objExcel = Nothing
End Sub
推荐阅读
- java - spring data JPA忽略查询方法上的fetchmode
- php - 如何将 USSD 代码从 PHP 发送到任何网络提供商?
- pattern-matching - HTML5 模式中的最大数量(不是最大位数)
- request - 一个请求参数可以在一个url中取多个值吗?
- mongodb - 带有构面的MongoDB聚合计数太慢了
- javascript - 使用 Angular7 直接下载“文件”
- css - 制表符过滤器 - 如何添加特定的 CSS 元素
- r - R基于列和列表合并两个数据帧
- java - 寻找大 O 复杂度。三种算法
- javascript - 如何使用 ng2-file-upload 以角度上传 .ply 文件