excel - 读取和列出用户输入的文件位置并在错误时退出的宏
问题描述
我目前有一个宏,可以读取用户输入的某些文件,下面的部分代码收集文件名。但是,当用户输入多个文件位置时,只会输入一个文件位置。
在 C 列中,我想输入所有文件位置的顺序,以便它们被列为:filelocation1、filelocaction2...等等。
这是我当前的代码:
Sub openfiles()
Dim Files As Variant
'open directory, filter by excel files, select files and place in array
SelectedFiles = Application.GetOpenFilename( _
FileFilter:="Excel Filter (*.xlsx), *.xlsx", _
MultiSelect:=True)
Application.ScreenUpdating = False 'update in background
If not IsArray(Files) Then
MsgBox "No files selected. Cannot continue."
Range("O" & Rows.Count).End(xlUp).Offset(1, 0) = "no files selected"
Exit Sub
Else
Range("O" & Rows.Count).End(xlUp).Offset(1, 0) = Files
End If
End Sub
解决方案
推荐阅读
- forms - 未收到 Formsubmit.co 激活电子邮件
- javascript - 为什么 navigator.mediaDevices.enumerateDevices() 返回不同的值?
- javascript - 无法读取 discord.js 中未定义的属性“缓存”
- ios - 如何在一个集合视图中获取多个集合单元而不创建 XIB
- laravel - laravel 图像验证总是失败
- typescript - 尝试返回地图时“没有重载匹配此调用”
- zoho - Zoho creator 与 zoho 图书的集成
- javascript - 如何在视频中制作多个缓冲区?(互动视频JAVASCRIPT)
- python - 使用 python 3.6 Tkinter 和 cx_Freeze 或 PyInstaller(使用 dlib)创建可执行文件,但由于 dlib,DLL 无法加载
- java - Thymeleaf with mule 无法解析资源下的 HTML 路径