从工作簿的列取值代码
求简化代码:
能不能把代码修改为从 D/我的文档/"矿井建设单位工程统一名称表"工作簿的"工程名称"工作表的d:d列取值
' 填到当前工作簿,"工程"工作表的m:m列?
' 简化下列单元格为整列
Sub 从其他工作簿取值()
Dim myObj As Object
' GetObject 返回工作表对象的引用
Set myObj = GetObject(ThisWorkbook.Path & "\矿井建设单位工程统一名称表.xls")
' 能不能把代码修改为从 D/我的文档/"矿井建设单位工程统一名称表"工作簿的"工程名称"工作表的d:d列取值
' 填到当前工作簿,"工程"工作表的m:m列?
' 简化下列单元格为整列
[m1] = myObj.Sheets(1).Cells(1, 4)
[m2] = myObj.Sheets(1).Cells(2, 4)
[m3] = myObj.Sheets(1).Cells(3, 4)
[m4] = myObj.Sheets(1).Cells(4, 4)
[m5] = myObj.Sheets(1).Cells(5, 4)
[m6] = myObj.Sheets(1).Cells(6, 4)
[m7] = myObj.Sheets(1).Cells(7, 4)
[m8] = myObj.Sheets(1).Cells(8, 4)
[m9] = myObj.Sheets(1).Cells(9, 4)
[m10] = myObj.Sheets(1).Cells(10, 4)
[m11] = myObj.Sheets(1).Cells(11, 4)
[m12] = myObj.Sheets(1).Cells(12, 4)
[m13] = myObj.Sheets(1).Cells(13, 4)
[m14] = myObj.Sheets(1).Cells(14, 4)
[m15] = myObj.Sheets(1).Cells(15, 4)
[m16] = myObj.Sheets(1).Cells(16, 4)
[m17] = myObj.Sheets(1).Cells(17, 4)
[m18] = myObj.Sheets(1).Cells(18, 4)
[m19] = myObj.Sheets(1).Cells(19, 4)
[m20] = myObj.Sheets(1).Cells(20, 4)
[m21] = myObj.Sheets(1).Cells(21, 4)
[m22] = myObj.Sheets(1).Cells(22, 4)
[m23] = myObj.Sheets(1).Cells(23, 4)
[m24] = myObj.Sheets(1).Cells(24, 4)
[m25] = myObj.Sheets(1).Cells(25, 4)
'关闭工作簿
myObj.Close
Set myObj = Nothing
[最优解释]
Worksheets("工程名称").Range("D:D").Copy Worksheets("工程").Range("M:M")