inserting a new row if a condition is true

May 30, 2012 at 14:02:18
Specs: Windows 7
hi all
i have worksheet with 6 sheet. I need to insert a new row to the top of sheet2 if a condition on sheet1 returns True and then copy some of the values in the sheet1 to the inserted row in sheet2.
how can i do this?

See More: inserting a new row if a condition is true

Report •

May 30, 2012 at 18:55:12
You will need some VBA code to do this. Formulas cannot insert rows or copy data.

Unfortunately you have not provided enough information for any code to be offered. We would need to know the "condition" to monitor and the location of the values to be copied.

Click Here Before Posting Data or VBA Code ---> How To Post Data or Code.

Report •

May 31, 2012 at 09:17:03
hi DerbyDad03
here is some more information that may help.
i have 6 column in each sheet that a user will fill data in 4 of them. 2 others are usual math formula like auto sum and plus that acting in entered data by the user.
something like this:
1 opr person qnt price total subtotal
2 buy sam 5 100 500 5000
3 sell dina 3 50 150 1500
all sheets are the same this. in sheet2 cell G2 I have a condition that check if sheet1 cell B2="sam" then return "True" else return ""(noll). now i need another condition in sheet 2 that check if cell G2="true" insert a new row on top of row 2 and copy cells A2 to F2 in to it but write "sell" in-front of "buy" or write "buy" in-front of "sell".
this is all i need and i hope you can help me by this.

Report •

May 31, 2012 at 09:33:24
First, it appears that you did not read the instructions on how to post data in this forum. The instructions can be found by clicking on the blue line at the bottom of this post.

Please read those instuctions and repost your data.

Second, I don't know what you mean by "write "sell" in-front of "buy" or write "buy" in-front of "sell".

Perhaps you should post a before and after example of your data.

Third, if G2 is what determines whether a row should be inserted or not, what will happen once the Row is inserted and G2 has now moved down to G3? Is the code supposed to check G3, and then G4 and then G5 each time a row is inserted?

This does not make sense to me.

Click Here Before Posting Data or VBA Code ---> How To Post Data or Code.

Report •

Related Solutions

June 1, 2012 at 04:17:39
Here is what I have in sheet1 that a user inserted.
	A	B	C	D	E	F	G	H
2	Buy	sami	4	100	400			
3	sell	sami	3	70	210			
4	sell	dina	2	120	240			

In sheet2 I have the same table and I need this condition that I put it in G2
	A	B	C	D	E	F	G	H
2	sell	sasha	2	100	200		If(sheet1!B2=”sami”,true,false)	
3	buy	yari	1	120	120			
4	buy	sasha	5	100	500			

Now I need that in sheet2 when G2 is “true” a row inserted from A2 to E2 and values in the same cells from sheet1 to be copied into inserted cells and also if sheet1 A2=”sell” then sheet2 A2=”buy” or if sheet1 A2=”buy” then sheet2 A2=”sell”. So whenever user write “sami” in column B of sheet1 the 5cells should be inserted to the row2 of sheet2 and the values of the row that contain “sami” will be put in to the inserted cells.

Report •

Ask Question