VBA code for Insert new row based on criteria

parkroyalduo

New Member
Joined
Feb 28, 2014
Messages
2
Hoping someone can assist.
I have a worksheet which contains product line item data. (15 columns across, 400 rows down)
I need help with writing code that can Copy and Paste a column (in Column S) from another worksheet and insert a new row based on the criteria of "No" in Column T.

It would only need to insert one new row at the first "No".

Hope there is a solution available. I am at a very basic level of coding so any help would be appreciated!

Thanks
PRD
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
if you just want to insert a row after the first no in column T then the following code will work.

Code:
sub add_row_after_no_in_T
dim LR as long
Dim I as Long
LR = .Cells(.Rows.Count, "T").End(xlUp).Row
For I = 1 to LR
   If cells(I,20).value = "No" Then
           cells(I +1, 20).entirerow.insert
           exit sub
           else
   end if
next I
end
To copy and paste the information, you need to write the code for that. If you're not sure how to write it, I suggest recording a macro to copy the details after the macro has been run, then inserting that code.
I hope that helps.
 
Upvote 0

Forum statistics

Threads
1,222,907
Messages
6,168,963
Members
452,228
Latest member
just4jeffrey

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