copy rows to another worksheet

bionicjake

New Member
Joined
Aug 4, 2011
Messages
2
Please help!

I have a price list that is approximately 300 rows. I want some direction on how to automatically populate another sheet within the workbook with any row that has >0 in the quantity column.

This must be compatible in Excel 2007 and 2003.
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
Assuming Column A has your quantity, change to suit. Change the sheet name 'list' to suit your sheet name

Code:
LR = Range("A" & Rows.Count).End(xlUp).Row
    For i = LR To 1 Step -1
    If Range("A" & i).Value > 0 Then Rows(i).Copy Destination:=Sheets("list").Cells(Rows.Count, "A").End(xlUp)
    Next i
 
Upvote 0
I've never implemented anything beyond a formula. I copy into the VB code for that worksheet and nothing happened?

:confused:
 
Upvote 0
Did you change the sheet name to the one you want results? Do we need to create another sheet just for the results? Are your quantities in Column A?
Copy this into your VBA window and close it down, select View, Macros, Run and select CopyData then click Run
Code:
Sub CopyData()
 Dim LR As Long, i As Long
LR = Range("A" & Rows.Count).End(xlUp).Row
    For i = LR To 1 Step -1
    If Range("A" & i).Value > 0 Then Rows(i).Copy Destination:=Sheets("list").Cells(Rows.Count, "A").End(xlUp)
    Next i
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,569
Messages
6,179,605
Members
452,928
Latest member
VinceG

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top