copy row dependant on certain cell

vac

Board Regular
Joined
May 21, 2002
Messages
211
Hi,
Im trying to copy rows from a parts list to an invoice sheet only when there is a number in the quantity column, ie
part price quantity
nail £1 1
gun £23
glue £2 2


In the above example I would like only the rows with figures in the quantity column to be copied across to another sheet, result should be
part price quantity
nail £1 1
glue £2 2

Many Thanks
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)

AgentSilverfern

Board Regular
Joined
Oct 16, 2003
Messages
51
Hi Vac,
Why don't you try this.
When u have the sheet with your parts list visible select any cell in the top row of your spreadsheet i.e. one of the titles like part or price, then go to the Data menu, select Filter and then Auto Filter. A series of drop down arrow buttons should then appear next to the names of all your headers.
Click on the button next to the quantity header.
A drop down list should appear, near the bottom of which should appear the option (non blanks).
Select this option and all those parts with no quantity should disappear from your list. They are still there, just temporarily filtered out.
You can now copy the filtered list and paste it into another sheet. It will not paste the filtered out information.
When you are done you can return to your list click on the drop down button again and select (none) to restore your parts list to its former state.
Hope this helps,
Agent Silverfern
 

vac

Board Regular
Joined
May 21, 2002
Messages
211
Thanks for the reply, but I was hoping to be able to do this with a macro.
. I used to have a piece of code for this sort of thing from a previous thread , but unfortunately have lost the link...Doh
Any other suggestions
 

north19701

Active Member
Joined
Jun 17, 2003
Messages
491
Code:
Sub Macro1()
Range("c1:c" & Range("c65536").End(xlUp).Row).SpecialCells(xlCellTypeConstants).EntireRow.Copy _
Destination:=Sheets("Sheet2").Range("a1")
End Sub

this should get you started. are the values in column C based on a formula, though? If so, the code will have to change.
 

AgentSilverfern

Board Regular
Joined
Oct 16, 2003
Messages
51
Vac,

In actual fact if you don't mind having the filters on your spreadsheet all the time. You can record a macro of all the steps I gave you subsequent to turning the filters on. This will work whether or not your values are based on formulas.

Agent Silverfern
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,168,037
Messages
5,856,962
Members
431,841
Latest member
jaybeem

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
Top