Hello,
I wanted to make macro for copy and past range of data to another workbook. Problem is that range need to change! I have tryed to use code:
Dim active_sheet As Long
Dim new_wb As Workbook
Dim iRow As Long
Dim oWbk As Workbook
Dim nWbk As Workbook
Dim nWst As Worksheet
Set oWbk = ActiveWorkbook
Set nWbk = Workbooks.Add()
active_sheet = oWbk.ActiveSheet.Index
For iRow = 27 To r 'nuo 27 eilutes
val = oWbk.Sheets.Item(active_sheet).Cells(iRow, 6)
'MsgBox val
If val = "" Then
MsgBox "ALL DONE!!!"
Exit For
End If
nWst.Cells.Range("j16:br16") = oWbk.Sheets.Item(active_sheet).Range("z27:ch27").Value
nWst.Cells.Range("Q22") = oWbk.Sheets.Item(active_sheet).Cells(iRow, "DC")
nWst.Cells.Range("Q23") = oWbk.Sheets.Item(active_sheet).Cells(iRow + 2, "DC")
Next iRow
there is more of the code but no need to copy all! this code works without problems but if i try to change line
nWst.Cells.Range("j16:br16") = oWbk.Sheets.Item(active_sheet).Range("z27:ch27").Value
to
nWst.Cells.Range("j16:br16") = oWbk.Sheets.Item(active_sheet).Range("z(iRow):ch(iRow)").Value
there is error
Please help me!
Bookmarks