monaleasa001
04-14-2008, 10:15 AM
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:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
First Last Offence Retained 1st. AMT PMT Method Receipt # Bal Fwd Date AMT Pmt Method Receipt # Bal Fwd Date AMT Pmt Method Receipt # Bal Fwd Date AMT Pmt Method Receipt # Bal Fwd
Ashley Brown Speeding 0 to 15 over 04-Mar-08 100 Cheque A4545 267.5 #### 150 Debit CIBC 456 118 #### 75 Cheque CIBC 78 43 ######## 43 Cheque CIBC 88 0
Frank Hiller Stunt--Speeding 02-Jan-08 100 Cash cash 267.5 #### 50 Cash cash 218 #### 100 Cash cash ## 02-Apr-08 118 Cash cash 0
jane doe Speeding 30 To 49 over 14-Feb-08 50 Cheque 23232 317.5 #### 50 Cheque TD 023 268 #### 100 Cheque td32 ## ######## 168 Cheque td35 0
And this is how I need it to look after the information is moved and re-inserted:
1 2 3 4 5 6 7 8
First Last Offence Date 1st. AMT PMT Method Receipt # Bal Fwd
Frank Hiller Stunt--Speeding 02-Jan-08 100 Cash cash 267.5
19-Feb-08 50 Cash cash 217.5
06-Mar-08 100 Cash cash 117.5
02-Apr-08 117.5 Cash cash 0
jane doe Speeding 30 To 49 over 14-Feb-08 50 Cheque 23232 317.5
14-Feb-08 50 Cheque TD 023 267.5
20-Feb-08 100 Cheque td32 167.5
10-Mar-08 167.5 Cheque td35 0
Ashley Brown Speeding 0 to 15 over 04-Mar-08 100 Cheque A4545 267.5
04-Feb-08 150 Debit CIBC 456 117.5
28-Feb-08 75 Cheque CIBC 78 42.5
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
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:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
First Last Offence Retained 1st. AMT PMT Method Receipt # Bal Fwd Date AMT Pmt Method Receipt # Bal Fwd Date AMT Pmt Method Receipt # Bal Fwd Date AMT Pmt Method Receipt # Bal Fwd
Ashley Brown Speeding 0 to 15 over 04-Mar-08 100 Cheque A4545 267.5 #### 150 Debit CIBC 456 118 #### 75 Cheque CIBC 78 43 ######## 43 Cheque CIBC 88 0
Frank Hiller Stunt--Speeding 02-Jan-08 100 Cash cash 267.5 #### 50 Cash cash 218 #### 100 Cash cash ## 02-Apr-08 118 Cash cash 0
jane doe Speeding 30 To 49 over 14-Feb-08 50 Cheque 23232 317.5 #### 50 Cheque TD 023 268 #### 100 Cheque td32 ## ######## 168 Cheque td35 0
And this is how I need it to look after the information is moved and re-inserted:
1 2 3 4 5 6 7 8
First Last Offence Date 1st. AMT PMT Method Receipt # Bal Fwd
Frank Hiller Stunt--Speeding 02-Jan-08 100 Cash cash 267.5
19-Feb-08 50 Cash cash 217.5
06-Mar-08 100 Cash cash 117.5
02-Apr-08 117.5 Cash cash 0
jane doe Speeding 30 To 49 over 14-Feb-08 50 Cheque 23232 317.5
14-Feb-08 50 Cheque TD 023 267.5
20-Feb-08 100 Cheque td32 167.5
10-Mar-08 167.5 Cheque td35 0
Ashley Brown Speeding 0 to 15 over 04-Mar-08 100 Cheque A4545 267.5
04-Feb-08 150 Debit CIBC 456 117.5
28-Feb-08 75 Cheque CIBC 78 42.5
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