我有两个工作簿,wb
和wb2
。我想做什么,
将Nov
中的数据复制到Nov Temp
//中的工作表wb
//此部分代码正常运行。
将wb
中的特定范围复制到wb2
。 //我尝试使用Rng
来设置值,但由于我处理范围的方式,它可能无法正常工作。 <{1}}中的Rng
突出显示为
编译错误;找不到方法或数据成员。
请帮忙......
(myRange = sht.Rng.Value)
答案 0 :(得分:0)
现在可以使用,删除myRange并单独使用Rng。
Option Explicit
Sub cont()
Application.Volatile
Dim sht As Worksheet
'Dim myRange As Variant
Dim Rng As Range
Dim Lastrow, ecol, eRow As Long
Dim station As String
Dim wb As Workbook, wb2 As Workbook
Set wb = ActiveWorkbook
wb.Sheets("Nov").Activate
eRow = Cells(Rows.Count, 2).End(xlUp).Row
station = Range("B2").Value
Range(Cells(2, 2), Cells(eRow, 2)).Copy
MsgBox "Transfer data for station: " & station
wb.Sheets("Nov Template").Activate
Set sht = ActiveWorkbook.Sheets("Nov Template")
ecol = sht.UsedRange.Columns.Count
sht.Range(Cells(1, 2), Cells(eRow, 2)).PasteSpecial xlPasteValues
With ActiveSheet.UsedRange
Lastrow = .Rows(.Rows.Count).Row
Set Rng = Range(Cells(1, "C"), Cells(Lastrow, ecol))
'myRange = sht.Rng.Value
End With
Workbooks.Open "G:\Mean2std\Merge NDj (2).xlsm"
Set wb2 = ActiveWorkbook
'wb2.Worksheets("GM").Range("B3:AO32").Value = myRange
wb2.Worksheets("GM").Range("B3:AO32").Value = Rng.Value
wb2.Close SaveChanges:=True
End Sub