I have two workbooks, wb
and wb2
. What I want to do,
Copy data from sheet
Nov
to sheetNov Temp
inwb
// this part, code is working.Copy specific range in
wb
towb2
. // I try to useRng
to set value but it didn't work possibly due to the way I address my range.Rng
in(myRange = sht.Rng.Value)
is highlighted forcompile error; method or data member not found.
Please help...
Option Explicit
Sub cont()
Application.Volatile
Dim sht As Worksheet
Dim myRange As Variant
Dim Rng As Range
Dim Lastrow, ecol, eRow As Integer
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
On Error GoTo 0
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.Close SaveChanges:=True
End Sub