Harshil Mehta
Board Regular
- Joined
- May 14, 2020
- Messages
- 85
- Office Version
- 2013
- Platform
- Windows
About the code: It copies sheet7.RangeB11 till the last used column when the word MAPPED is found in sheet7.RangeA11 and so on; paste them in the said destination.
Problem: I have large data set (around 2,00,000 lines) and this code consumes a lot of time when compared to the task implemented manually.
Could any one help me optimize this code?
Next
End With
End Sub
Problem: I have large data set (around 2,00,000 lines) and this code consumes a lot of time when compared to the task implemented manually.
Could any one help me optimize this code?
VBA Code:
Sub cf()
Dim lr, lc As Long
With Sheet7
lr = .Cells(Rows.Count, 1).End(xlUp).Row
For H = 11 To lr
lc = .Cells(H, Columns.Count).End(xlToLeft).Column
If .Cells(H, 1) = "Mapped" Or .Cells(H, 1) = "mapped" Then
.Range(.Cells(H, 2), Cells(H, lc)).Copy
Sheet3.Cells(Rows.Count, 2).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
End If
Next
End With
End Sub