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
A
B
C
D
E
F
G
H
ID
EFFDT
ACTION
ANNUAL_RT
EFFDT
ACTION
COMPRATE
CD
AX1234
01-01-10
PRO
200
01-01-10
PRO
10
FLXPCT
AX1234
01-01-10
PRO
60
LUNCH
AX1234
01-04-10
MER
300
01-04-10
MER
20
FLXPCT
AX1234
01-04-10
MER
60
LUNCH

<TBODY>
</TBODY>


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

Fig. 2
A
B
C
D
E
ID
EFFDT
ACTION
ANNUAL_RT
CD
AX1234
01-01-10
PRO
200
ANNUAL
AX1234
01-01-10
PRO
10
FLXPCT
AX1234
01-01-10
PRO
60
LUNCH
AX1234
01-04-10
MER
300
ANNUAL

<TBODY>
</TBODY>


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

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().

Forum statistics

Threads
1,213,552
Messages
6,114,278
Members
448,559
Latest member
MrPJ_Harper

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