Copy certain rows that have a certain value range in a column to a new worksheet

ambarish

New Member
Joined
Nov 8, 2012
Messages
2
Hi,

Could you please help me with a VBA code that would look at column M in sheet 1 and if any cells in column M =>10,000,000 then this entire row gets copied on another worksheet. Thanks so much for your help.

Ambarish
 

Some videos you may like

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.

pboltonchina

Well-known Member
Joined
Apr 24, 2008
Messages
1,095
Try this on a copy of your data as it is untested
Sub Copy()
Application.ScreenUpdating = False
Dim LR As Long, i As Long
LR = Range("M" & Rows.count).End(xlUp).Row
For i = LR To 1 Step -1
If Range("M" & i).Value => "10,000,000" Then Rows(i).Copy Destination:=Sheets("Sheet2").Cells(Rows.count, "A").End(xlUp).Offset(1)
End If
Next i
Application.ScreenUpdating = True
End Sub
 

ambarish

New Member
Joined
Nov 8, 2012
Messages
2
Thanks for your reply. I get an error message - Compile Error: (End if without block if). Could you please help? Thanks again.
 

Watch MrExcel Video

Forum statistics

Threads
1,090,549
Messages
5,415,214
Members
403,573
Latest member
ballardgirl

This Week's Hot Topics

Top