Script out of range

  • Thread starter Thread starter J
  • Start date Start date
J

J

Hi.. well i'm back again.. this glitch is more than I can figure out... The
macro seems to be putting the information in only "one" column...

the information that needs to be inserted is going down to the 5th row in
Column D and putting "all" of the information there, instead of placing each
row to the right of Column D. Does that make sense?

Thanks, J
 
Here's the code... Thanks,

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

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

End Sub


This is how it imports:

First Name Last Name B2 - H.T.A. Offence A1 - Date Retained AA-TAD:0-2:
1st. AMT AA-TAD:0-3:PMT Method AA-TAD:0-4:Receipt #
Frank Hiller Stunt--Speeding 02-Jan-08 100 Cash cash
jane doe Speeding 30 To 49 over 14-Feb-08 50 Cheque 23232
Ashley Brown Speeding 0 to 15 over 04-Mar-08 100 Cheque A4545


And this is how I need it to look:

First Name Last Name B2 - H.T.A. Offence A1 - Date Retained AA-TAD:0-2:
1st. AMT AA-TAD:0-3:PMT Method AA-TAD:0-4:Receipt #
Frank Hiller Stunt--Speeding 02-Jan-08 100 Cash cash
19-Feb-08 50 Cash cash
06-Mar-08 100 Cash cash
02-Apr-08 117.5 Cash cash

Ashley Brown Speeding 0 to 15 over 04-Mar-08 100 Cheque A4545
04-Feb-08 150 Debit CIBC 456
28-Feb-08 75 Cheque CIBC 78
21-Mar-08 42.5 Cheque CIBC 88


Thanks, J
 
I found your previous posting. This line:

Destination:=.Cells(X - 9 + DataRow + Z, MoveToColumn)

Tells VBA to put everything in column D. MoveToColumn = 4 which = D.
To move it to the right of column D, you will either need to change the
value of MoveToColumn or add another value to it in the statement above.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top