unknownymous
Board Regular
- Joined
- Sep 19, 2017
- Messages
- 249
- Office Version
- 2016
- Platform
- Windows
Hello Guys,
Hope all is well.
I have a sheet with more than more or less 100k lines. I need to trim the data first by omitting rows with "0" or blank as Value in Row R (Sheet 1). I found below code but it's taking much time probably because the file is too large.
Sub DeleteRow() 'DeleteRow ot Value is Zero
Dim MyRange As Range
Set MyRange = Range("R1:R500000")
Do
Set myCell = MyRange.Find("0", LookIn:=xlValues)
If Not myCell Is Nothing Then
myCell.EntireRow.Delete
End If
Loop While Not myCell Is Nothing
End Sub
Once done, I need to create 2 tab sheets on the same file namely - "Team P" and "Team N". Data is given in is Sheet 1 column B
Team P sheet - Copy those positive change from Sheet 1 (column B)
Team N sheet - Copy those negative change from Sheet 1 (column B)
I found and tweak this code but its taking too much time.
Sub CopyPositive ()
Dim i As Range
For Each i In Range("B1:B250000")
If i.Value > 0 Then
i.Select
ActiveCell.Rows("1:1").EntireRow.Select
Selection.Copy
Sheets("Team P").Range("A250000").End(xlUp).Offset(1, 0).PasteSpecial
End If
Next i
End Sub
Source: Copy rows to other sheet if cell value is greater than zero - OzGrid Free Excel/VBA Help Forum
Any thoughts will be much appreciated.
Hope all is well.
I have a sheet with more than more or less 100k lines. I need to trim the data first by omitting rows with "0" or blank as Value in Row R (Sheet 1). I found below code but it's taking much time probably because the file is too large.
Sub DeleteRow() 'DeleteRow ot Value is Zero
Dim MyRange As Range
Set MyRange = Range("R1:R500000")
Do
Set myCell = MyRange.Find("0", LookIn:=xlValues)
If Not myCell Is Nothing Then
myCell.EntireRow.Delete
End If
Loop While Not myCell Is Nothing
End Sub
Once done, I need to create 2 tab sheets on the same file namely - "Team P" and "Team N". Data is given in is Sheet 1 column B
Team P sheet - Copy those positive change from Sheet 1 (column B)
Team N sheet - Copy those negative change from Sheet 1 (column B)
I found and tweak this code but its taking too much time.
Sub CopyPositive ()
Dim i As Range
For Each i In Range("B1:B250000")
If i.Value > 0 Then
i.Select
ActiveCell.Rows("1:1").EntireRow.Select
Selection.Copy
Sheets("Team P").Range("A250000").End(xlUp).Offset(1, 0).PasteSpecial
End If
Next i
End Sub
Source: Copy rows to other sheet if cell value is greater than zero - OzGrid Free Excel/VBA Help Forum
Any thoughts will be much appreciated.