Rearranging data with VBA

procadman

New Member
Joined
May 25, 2018
Messages
9
This one seems simple but gets hairy as it goes on:

I have 2 columns of 182 rows of data (A + B)
I need to copy 2 rows of existing data (b10 & b11) ahead of each B cell containing current data.
I need to insert 2 blank rows below each A cell with current data.

This is what I have (Ignore dashes):
Col A Col B
-------data b10
-------data b11

data a13 data b13
data a14 data b14
data a15 data b15


This is what I need:
data a13 data b10
-----------data b11
-----------data b13
data a14 data b10
-----------data b11
-----------data b14
data a15 data b10
-----------data b11
-----------data b15


Since this is stand alone data perhaps the best idea would be to copy the existing data into blank cells, arranging it as needed.

Either way requires a progressive counter or multiple counters which is where I get lost.
 
Last edited:

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Correction:
Col A Col B
-------data b1
-------data b2
-------data b3

data a10 data b10
data a11 data b11
data a12 data b12


This is what I need:
data a10 data b1
-----------data b2
-----------data b10
-----------data b3data a11 data b1
-----------data b2
-----------data b11
-----------data b3
data a12 data b1
-----------data b2
-----------data b12
-----------data b3

Alternately I could have all of the rows in place, and simply replace/copy over the existing data:

data:
data a10 data b10
data a11 data b11
data a12 data b12

target cells:
data a10
-----------
-----------data b10
-----------
data a11
-----------
-----------data b11
-----------
data a12
-----------
-----------data b12
-----------


Another choice of target output could be all in one column:

data a10
(existing data)
(existing data)
data b10
(existing data)
data a11
(existing data)
(existing data)
data b11
(existing data




 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,177
Members
453,021
Latest member
Justyna P

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