Macros to append/merge records

eyee

New Member
Joined
Jan 12, 2012
Messages
11
Hi -

Fig. 1 below shows what I am trying create in Excel using a marcos. Rows that are populated in Columns A-D are primary records. Rows populated in Columns E-H are the secondary records appended to the primary. A row/space is added under the primary records starting with the 2nd secondary record.

Fig. 1[TABLE="width: 500"]
<TBODY>[TR]
[TD]A
[/TD]
[TD]B
[/TD]
[TD]C
[/TD]
[TD]D
[/TD]
[TD]E
[/TD]
[TD]F
[/TD]
[TD]G
[/TD]
[TD]H
[/TD]
[/TR]
[TR]
[TD]ID
[/TD]
[TD]EFFDT
[/TD]
[TD]ACTION
[/TD]
[TD]ANNUAL_RT
[/TD]
[TD]EFFDT
[/TD]
[TD]ACTION
[/TD]
[TD]COMPRATE
[/TD]
[TD]CD
[/TD]
[/TR]
[TR]
[TD]AX1234
[/TD]
[TD]01-01-10
[/TD]
[TD]PRO
[/TD]
[TD]200
[/TD]
[TD]01-01-10
[/TD]
[TD]PRO
[/TD]
[TD]10
[/TD]
[TD]FLXPCT
[/TD]
[/TR]
[TR]
[TD]AX1234
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]01-01-10
[/TD]
[TD]PRO
[/TD]
[TD]60
[/TD]
[TD]LUNCH
[/TD]
[/TR]
[TR]
[TD]AX1234
[/TD]
[TD]01-04-10
[/TD]
[TD]MER
[/TD]
[TD]300
[/TD]
[TD]01-04-10
[/TD]
[TD]MER
[/TD]
[TD]20
[/TD]
[TD]FLXPCT
[/TD]
[/TR]
[TR]
[TD]AX1234
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]01-04-10
[/TD]
[TD]MER
[/TD]
[TD]60
[/TD]
[TD]LUNCH
[/TD]
[/TR]
</TBODY>[/TABLE]


The data comes from a table where every row is a primary or secodary record, as per Fig. 2 below.

Fig. 2[TABLE="width: 500"]
<TBODY>[TR]
[TD]A
[/TD]
[TD]B
[/TD]
[TD]C
[/TD]
[TD]D
[/TD]
[TD]E
[/TD]
[/TR]
[TR]
[TD]ID
[/TD]
[TD]EFFDT
[/TD]
[TD]ACTION
[/TD]
[TD]ANNUAL_RT
[/TD]
[TD]CD
[/TD]
[/TR]
[TR]
[TD]AX1234
[/TD]
[TD]01-01-10
[/TD]
[TD]PRO
[/TD]
[TD]200
[/TD]
[TD]ANNUAL
[/TD]
[/TR]
[TR]
[TD]AX1234
[/TD]
[TD]01-01-10
[/TD]
[TD]PRO
[/TD]
[TD]10
[/TD]
[TD]FLXPCT
[/TD]
[/TR]
[TR]
[TD]AX1234
[/TD]
[TD]01-01-10
[/TD]
[TD]PRO
[/TD]
[TD]60
[/TD]
[TD]LUNCH
[/TD]
[/TR]
[TR]
[TD]AX1234
[/TD]
[TD]01-04-10
[/TD]
[TD]MER
[/TD]
[TD]300
[/TD]
[TD]ANNUAL
[/TD]
[/TR]
</TBODY>[/TABLE]


Every column B (EFFDT) change is a primary record. Secondary records need to be appended/merged to the side of the primary record like in the Fig. 1.
How then do I create a macros to append or merge the secondary records for each EFFDT change and insert the correct # of row/space below the primary records? Hopefully this all makes sense....
 

Excel Facts

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

Forum statistics

Threads
1,223,236
Messages
6,170,906
Members
452,366
Latest member
TePunaBloke

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