相关疑难解决方法(0)

VBA错误1004 - 范围类的select方法失败

第一次海报,所以如果有任何格式或指导我没有遵守,请告诉我,以便我可以解决它.

所以我基本上要求用户提供excel文件的文件目录,然后设置一些变量(最初设置为public作为项目变量,因为这些变量在其他地方被使用和更改).我还添加了行来将这些变量设置为空(以防万一,我不认为它应该重要).然后我将这些变量设置为我想要访问的excel文件,工作簿和工作表.

Dim filepath as String
filePath = CStr(fileDialog)              'ask file dir, set to string
Dim sourceXL As Variant                  'these three were orig project variables
Dim sourceBook As Variant
Dim sourceSheet As Variant
Dim sourceSheetSum As Variant

Set sourceXL = Nothing                    'set to nothing in case...?
Set sourceBook = Nothing
Set sourceSheet = Nothing
Set sourceSheetSum = Nothing

Set sourceXL = Excel.Application          'set to the paths needed
Set sourceBook = sourceXL.Workbooks.Open(filePath)
Set sourceSheet = sourceBook.Sheets("Measurements")
Set sourceSheetSum = sourceBook.Sheets("Analysis Summary") …
Run Code Online (Sandbox Code Playgroud)

vb.net vba excel-vba excel-2010 powerpoint-vba

17
推荐指数
2
解决办法
11万
查看次数

标签 统计

excel-2010 ×1

excel-vba ×1

powerpoint-vba ×1

vb.net ×1

vba ×1