Insert rows and copy data

philcart

Board Regular
Joined
Feb 12, 2003
Messages
177
Hi,
I need help coding the following please –
I have an Excel 2007 worksheet with customer details in cols A to J, with col B containing the customer’s primary reference number.
Some customers have secondary reference numbers in col K, ranging from 1 ref upwards. If more than 1, the refs are separated by commas e.g. AS123,DF4567,JK987456,VB753159 (note – no spaces between refs, and no comma after the last one)

What I need the code to do is –

While there is data in col B, work down col K row by row starting at K2

If cell in col K is blank – do nothing, and look at next row

If cell in col K e.g K5 is nonblank – insert a new row for each ref. i.e. if K5 contained 4 refs, insert 4 new rows beneath row 5, and copy the 4 refs into cells B6, B7, B8, & B9. Then copy the relevant values in cells A5, and C5 to J5 down the 4 new rows.

In a nutshell – I need to amalgamate customers’ primary and secondary refs into one list

This is a variance of my initial problem which was kindly solved by Craig at
http://www.mrexcel.com/forum/showthread.php?t=563410&goto=newpost

Any help will be much appreciated
Cheers,
Phil
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.

Forum statistics

Threads
1,224,542
Messages
6,179,421
Members
452,913
Latest member
JWD210

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