Help needed creating "insert" Macro

monaleasa

New Member
Joined
Mar 10, 2008
Messages
10
I need to create a macro that will move information from a range of columns and then insert them under existing information in another column.

here's my example, this is what I'm starting with:

There are only 3 rows in this worksheet and I have numbered the columns just for reference in solving this problem: Anyway, this is how it looks when I import the records:

<table x:str="" style="border-collapse: collapse; width: 972pt;" border="0" cellpadding="0" cellspacing="0" width="1293"><col style="width: 41pt;" width="54"> <col style="width: 40pt;" width="53"> <col style="width: 60pt;" width="80"> <col style="width: 65pt;" width="86"> <col style="width: 52pt;" width="69"> <col style="width: 46pt;" width="61"> <col style="width: 60pt;" width="80"> <col style="width: 50pt;" width="67"> <col style="width: 34pt;" width="45"> <col style="width: 32pt;" width="43"> <col style="width: 29pt;" width="39"> <col style="width: 49pt;" width="65"> <col style="width: 26pt;" width="34"> <col style="width: 35pt;" width="46"> <col style="width: 31pt;" width="41"> <col style="width: 28pt;" width="37"> <col style="width: 47pt;" width="63"> <col style="width: 24pt;" width="32"> <col style="width: 60pt;" width="80"> <col style="width: 29pt;" width="39"> <col style="width: 27pt;" width="36"> <col style="width: 47pt;" width="63"> <col style="width: 60pt;" width="80"> <tbody><tr style="height: 15.75pt;" height="21"> <td class="xl24" style="height: 15.75pt; width: 41pt;" height="21" width="54">1</td> <td class="xl24" style="border-left: medium none; width: 40pt;" width="53">2</td> <td class="xl24" style="border-left: medium none; width: 60pt;" width="80">3</td> <td class="xl24" style="border-left: medium none; width: 65pt;" width="86">4</td> <td class="xl24" style="border-left: medium none; width: 52pt;" width="69">5</td> <td class="xl24" style="border-left: medium none; width: 46pt;" width="61">6</td> <td class="xl24" style="border-left: medium none; width: 60pt;" width="80">7</td> <td class="xl24" style="border-left: medium none; width: 50pt;" width="67">8</td> <td class="xl24" style="border-left: medium none; width: 34pt;" width="45">9</td> <td class="xl24" style="border-left: medium none; width: 32pt;" width="43">10</td> <td class="xl24" style="border-left: medium none; width: 29pt;" width="39">11</td> <td class="xl24" style="border-left: medium none; width: 49pt;" width="65">12</td> <td class="xl24" style="border-left: medium none; width: 26pt;" width="34">13</td> <td class="xl24" style="border-left: medium none; width: 35pt;" width="46">14</td> <td class="xl24" style="border-left: medium none; width: 31pt;" width="41">15</td> <td class="xl24" style="border-left: medium none; width: 28pt;" width="37">16</td> <td class="xl24" style="border-left: medium none; width: 47pt;" width="63">17</td> <td class="xl24" style="border-left: medium none; width: 24pt;" width="32">18</td> <td class="xl24" style="border-left: medium none; width: 60pt;" width="80">19</td> <td class="xl24" style="border-left: medium none; width: 29pt;" width="39">20</td> <td class="xl24" style="border-left: medium none; width: 27pt;" width="36">21</td> <td class="xl24" style="border-left: medium none; width: 47pt;" width="63">22</td> <td class="xl24" style="border-left: medium none; width: 60pt;" width="80">23</td> </tr> <tr style="height: 15.75pt;" height="21"> <td class="xl25" style="height: 15.75pt;" height="21">First</td> <td class="xl25" x:str="Last ">Last </td> <td class="xl25" x:str="Offence ">Offence </td> <td class="xl25">Retained</td> <td class="xl25" x:str="1st. AMT ">1st. AMT </td> <td class="xl25">PMT Method</td> <td class="xl25">Receipt #</td> <td class="xl25">Bal Fwd</td> <td class="xl25">Date</td> <td class="xl25">AMT</td> <td class="xl25">Pmt Method</td> <td class="xl25">Receipt #</td> <td class="xl25">Bal Fwd</td> <td class="xl25">Date</td> <td class="xl25">AMT</td> <td class="xl25">Pmt Method</td> <td class="xl25">Receipt #</td> <td class="xl25">Bal Fwd</td> <td class="xl25">Date</td> <td class="xl25">AMT</td> <td class="xl25">Pmt Method</td> <td class="xl25">Receipt #</td> <td class="xl25">Bal Fwd</td> </tr> <tr style="height: 15.75pt;" height="21"> <td class="xl25" style="height: 15.75pt;" height="21">Ashley</td> <td class="xl25">Brown</td> <td class="xl25">Speeding 0 to 15 over</td> <td class="xl26" x:num="39511" align="right">04-Mar-08</td> <td class="xl25" x:num="" align="right">100</td> <td class="xl25">Cheque</td> <td class="xl25">A4545</td> <td class="xl25" x:num="" align="right">267.5</td> <td class="xl26" x:num="39482" align="center">####</td> <td class="xl25" x:num="" align="right">150</td> <td class="xl25">Debit</td> <td class="xl25">CIBC 456</td> <td class="xl25" x:num="117.5" align="right">118</td> <td class="xl26" x:num="39506" align="center">####</td> <td class="xl25" x:num="" align="right">75</td> <td class="xl25">Cheque</td> <td class="xl25">CIBC 78</td> <td class="xl25" x:num="42.5" align="right">43</td> <td class="xl26" x:num="39528" align="center">########</td> <td class="xl25" x:num="42.5" align="right">43</td> <td class="xl25">Cheque</td> <td class="xl25">CIBC 88</td> <td class="xl25" x:num="" align="right">0</td> </tr> <tr style="height: 15.75pt;" height="21"> <td class="xl25" style="height: 15.75pt;" height="21">Frank</td> <td class="xl25">Hiller</td> <td class="xl25">Stunt--Speeding</td> <td class="xl26" x:num="39449" align="right">02-Jan-08</td> <td class="xl25" x:num="" align="right">100</td> <td class="xl25">Cash</td> <td class="xl25">cash</td> <td class="xl25" x:num="" align="right">267.5</td> <td class="xl26" x:num="39497" align="center">####</td> <td class="xl25" x:num="" align="right">50</td> <td class="xl25">Cash</td> <td class="xl25">cash</td> <td class="xl25" x:num="217.5" align="right">218</td> <td class="xl26" x:num="39513" align="center">####</td> <td class="xl25" x:num="" align="right">100</td> <td class="xl25">Cash</td> <td class="xl25">cash</td> <td class="xl25" x:num="117.5" align="center">##</td> <td class="xl26" x:num="39540" align="right">02-Apr-08</td> <td class="xl25" x:num="117.5" align="right">118</td> <td class="xl25">Cash</td> <td class="xl25">cash</td> <td class="xl25" x:num="" align="right">0</td> </tr> <tr style="height: 15.75pt;" height="21"> <td class="xl25" style="height: 15.75pt;" height="21">jane</td> <td class="xl25">doe</td> <td class="xl25">Speeding 30 To 49 over</td> <td class="xl26" x:num="39492" align="right">14-Feb-08</td> <td class="xl25" x:num="" align="right">50</td> <td class="xl25">Cheque</td> <td class="xl25" x:num="" align="right">23232</td> <td class="xl25" x:num="" align="right">317.5</td> <td class="xl26" x:num="39492" align="center">####</td> <td class="xl25" x:num="" align="right">50</td> <td class="xl25">Cheque</td> <td class="xl25">TD 023</td> <td class="xl25" x:num="267.5" align="right">268</td> <td class="xl26" x:num="39498" align="center">####</td> <td class="xl25" x:num="" align="right">100</td> <td class="xl25">Cheque</td> <td class="xl25">td32</td> <td class="xl25" x:num="167.5" align="center">##</td> <td class="xl26" x:num="39517" align="center">########</td> <td class="xl25" x:num="167.5" align="right">168</td> <td class="xl25">Cheque</td> <td class="xl25">td35</td> <td class="xl25" x:num="" align="right">0</td> </tr> </tbody></table>


And this is how I need it to look after the information is moved and re-inserted:

<table x:str="" style="border-collapse: collapse; width: 416pt;" border="0" cellpadding="0" cellspacing="0" width="554"><col style="width: 41pt;" width="54"> <col style="width: 40pt;" width="53"> <col style="width: 60pt;" width="80"> <col style="width: 66pt;" width="88"> <col style="width: 52pt;" width="69"> <col style="width: 47pt;" width="63"> <col style="width: 60pt;" width="80"> <col style="width: 50pt;" width="67"> <tbody><tr style="height: 15.75pt;" height="21"> <td class="xl28" style="height: 15.75pt; width: 41pt;" height="21" width="54">1</td> <td class="xl28" style="border-left: medium none; width: 40pt;" width="53">2</td> <td class="xl28" style="border-left: medium none; width: 60pt;" width="80">3</td> <td class="xl28" style="border-left: medium none; width: 66pt;" width="88">4</td> <td class="xl28" style="border-left: medium none; width: 52pt;" width="69">5</td> <td class="xl28" style="border-left: medium none; width: 47pt;" width="63">6</td> <td class="xl28" style="border-left: medium none; width: 60pt;" width="80">7</td> <td class="xl28" style="border-left: medium none; width: 50pt;" width="67">8</td> </tr> <tr style="height: 15.75pt;" height="21"> <td class="xl26" style="height: 15.75pt;" height="21">First</td> <td class="xl26">Last</td> <td class="xl26" x:str="Offence ">Offence </td> <td class="xl26"> Date</td> <td class="xl26" x:str="1st. AMT ">1st. AMT </td> <td class="xl26">PMT Method</td> <td class="xl26">Receipt #</td> <td class="xl26">Bal Fwd</td> </tr> <tr style="height: 15.75pt;" height="21"> <td class="xl26" style="height: 15.75pt;" height="21">Frank</td> <td class="xl26">Hiller</td> <td class="xl26">Stunt--Speeding</td> <td class="xl27" x:num="39449" align="right">02-Jan-08</td> <td class="xl26" x:num="" align="right">100</td> <td class="xl26">Cash</td> <td class="xl26">cash</td> <td class="xl26" x:num="" align="right">267.5</td> </tr> <tr style="height: 15.75pt;" height="21"> <td class="xl26" style="height: 15.75pt;" height="21">
</td> <td class="xl26">
</td> <td class="xl26">
</td> <td class="xl27" x:num="39497" align="right">19-Feb-08</td> <td class="xl26" x:num="" align="right">50</td> <td class="xl26">Cash</td> <td class="xl26">cash</td> <td class="xl26" x:num="" align="right">217.5</td> </tr> <tr style="height: 15.75pt;" height="21"> <td class="xl26" style="height: 15.75pt;" height="21">
</td> <td class="xl26">
</td> <td class="xl26">
</td> <td class="xl27" x:num="39513" align="right">06-Mar-08</td> <td class="xl26" x:num="" align="right">100</td> <td class="xl26">Cash</td> <td class="xl26">cash</td> <td class="xl26" x:num="" align="right">117.5</td> </tr> <tr style="height: 15.75pt;" height="21"> <td class="xl26" style="height: 15.75pt;" height="21">
</td> <td class="xl26">
</td> <td class="xl26">
</td> <td class="xl27" x:num="39540" align="right">02-Apr-08</td> <td class="xl26" x:num="" align="right">117.5</td> <td class="xl26">Cash</td> <td class="xl26">cash</td> <td class="xl26" x:num="" align="right">0</td> </tr> <tr style="height: 15.75pt;" height="21"> <td class="xl26" style="height: 15.75pt;" height="21">jane</td> <td class="xl26">doe</td> <td class="xl26">Speeding 30 To 49 over</td> <td class="xl27" x:num="39492" align="right">14-Feb-08</td> <td class="xl26" x:num="" align="right">50</td> <td class="xl26">Cheque</td> <td class="xl26" x:num="" align="right">23232</td> <td class="xl26" x:num="" align="right">317.5</td> </tr> <tr style="height: 15.75pt;" height="21"> <td class="xl26" style="height: 15.75pt;" height="21">
</td> <td class="xl26">
</td> <td class="xl26">
</td> <td class="xl27" x:num="39492" align="right">14-Feb-08</td> <td class="xl26" x:num="" align="right">50</td> <td class="xl26">Cheque</td> <td class="xl26">TD 023</td> <td class="xl26" x:num="" align="right">267.5</td> </tr> <tr style="height: 15.75pt;" height="21"> <td class="xl26" style="height: 15.75pt;" height="21">
</td> <td class="xl26">
</td> <td class="xl26">
</td> <td class="xl27" x:num="39498" align="right">20-Feb-08</td> <td class="xl26" x:num="" align="right">100</td> <td class="xl26">Cheque</td> <td class="xl26">td32</td> <td class="xl26" x:num="" align="right">167.5</td> </tr> <tr style="height: 15.75pt;" height="21"> <td class="xl26" style="height: 15.75pt;" height="21">
</td> <td class="xl26">
</td> <td class="xl26">
</td> <td class="xl27" x:num="39517" align="right">10-Mar-08</td> <td class="xl26" x:num="" align="right">167.5</td> <td class="xl26">Cheque</td> <td class="xl26">td35</td> <td class="xl26" x:num="" align="right">0</td> </tr> <tr style="height: 15.75pt;" height="21"> <td class="xl26" style="height: 15.75pt;" height="21">Ashley</td> <td class="xl26">Brown</td> <td class="xl26">Speeding 0 to 15 over</td> <td class="xl27" x:num="39511" align="right">04-Mar-08</td> <td class="xl26" x:num="" align="right">100</td> <td class="xl26">Cheque</td> <td class="xl26">A4545</td> <td class="xl26" x:num="" align="right">267.5</td> </tr> <tr style="height: 15.75pt;" height="21"> <td class="xl26" style="height: 15.75pt;" height="21">
</td> <td class="xl26">
</td> <td class="xl26">
</td> <td class="xl27" x:num="39482" align="right">04-Feb-08</td> <td class="xl26" x:num="" align="right">150</td> <td class="xl26">Debit</td> <td class="xl26">CIBC 456</td> <td class="xl26" x:num="" align="right">117.5</td> </tr> <tr style="height: 15.75pt;" height="21"> <td class="xl26" style="height: 15.75pt;" height="21">
</td> <td class="xl26">
</td> <td class="xl26">
</td> <td class="xl27" x:num="39506" align="right">28-Feb-08</td> <td class="xl26" x:num="" align="right">75</td> <td class="xl26">Cheque</td> <td class="xl26">CIBC 78</td> <td class="xl26" x:num="" align="right">42.5</td> </tr> </tbody></table>

Also, There will only be 3 entries for each client.
This is a copy of the macro that I have so far:

Sub MoveRow2Data()
Dim X As Long, Z As Long
Dim LastColumn As Long
Const StartCol As Long = 9
Const GroupCount As Long = 5
Const MoveToColumn As Long = 4
Const DataRow As Long = 2
With Worksheets("TrustDepositCSVfile")
LastColumn = .Cells(DataRow, .Columns.Count).End(xlToLeft).Column
For X = StartCol To LastColumn Step 5
For Z = 0 To GroupCount - 1
.Cells(DataRow, X + Z).Copy _
Destination:=.Cells(X - 9 + DataRow + Z, MoveToColumn)
Next
Next
.Cells(DataRow, StartCol).Resize(1, LastColumn - _
StartCol + 1).ClearContents
End With
End Sub


Can anyone help me create this macro? Thanks, Monaleasa
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.

Forum statistics

Threads
1,215,326
Messages
6,124,270
Members
449,149
Latest member
mwdbActuary

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