This will work:.._
_...This will also work…._Code:Sub STEP6() Dim w1 As Workbook Set w1 = Workbooks.Open("C:\Users\WolfieeeStyle\Desktop\Upstox\Merge.xlsx") ' change the file path ' convert formula result to values --- Copy 3145728 cells 3145728 Cells in 3 Whole columns.JPG : https://imgur.com/kQYSQfg w1.Worksheets.Item(1).Columns("I:K").Copy w1.Worksheets.Item(1).Columns("I:K").PasteSpecial Paste:=xlPasteValuesAndNumberFormats w1.Save w1.Close End Sub
_.........But it is not good - you copy 3 x 1048576 = 3145728 cellsCode:Sub STEP6() Dim w1 As Workbook Set w1 = Workbooks.Open("C:\Users\WolfieeeStyle\Desktop\Upstox\Merge.xlsx") ' change the file path ' convert formula result to values --- Copy 3145728 cells 3145728 Cells in 3 Whole columns.JPG : https://imgur.com/kQYSQfg w1.Worksheets.Item(1).Columns("I:K").Value = w1.Worksheets.Item(1).Columns("I:K").Value w1.Save w1.Close End Sub
3145728 Cells in 3 Whole columns.JPG : https://imgur.com/kQYSQfg
Attachment 2795
_.................This is better:-
3 x Lr Cells.JPG : https://imgur.com/LaIBKQL
Attachment 2796
Code:Sub STEP6() Dim w1 As Workbook Set w1 = Workbooks.Open("C:\Users\WolfieeeStyle\Desktop\Upstox\Merge.xlsx") ' change the file path Dim Lr As Long: Let Lr = w1.Worksheets.Item(1).Range("K" & w1.Worksheets.Item(1).Rows.Count & "").End(xlUp).Row ' convert formula result to values ---- 3 x Lr cells 3 x Lr Cells.JPG : https://imgur.com/LaIBKQL w1.Worksheets.Item(1).Range("I1:K" & Lr & "").Value = w1.Worksheets.Item(1).Range("I1:K" & Lr & "").Value Wb1.Save Wb1.Close End Sub
_......................................This is best
Code:Sub STEP6() Dim Wb1 As Workbook, Ws1 As Worksheet Set Wb1 = Workbooks.Open("C:\Users\WolfieeeStyle\Desktop\Upstox\Merge.xlsx") ' change the file path Set Ws1 = Wb1.Worksheets.Item(1) Dim Lr As Long: Let Lr = Ws1.Range("K" & Ws1.Rows.Count & "").End(xlUp).Row ' convert formula result to values ---- 3 x Lr cells 3 x Lr Cells.JPG : https://imgur.com/LaIBKQL Ws1.Range("I1:K" & Lr & "").Value = Ws1.Range("I1:K" & Lr & "").Value Wb1.Save Wb1.Close End Sub




Reply With Quote

Bookmarks