View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Rick Rothstein \(MVP - VB\)[_1682_] Rick Rothstein \(MVP - VB\)[_1682_] is offline
external usenet poster
 
Posts: 1
Default automaticaly moving information

I didn't get the impression this was being done in an already populated
column (mainly because the example showed the starting row as 2); but, of
course, given the example nature of the message, you could very well be
right.

Rick


"Joel" wrote in message
...
Rick: I think you have to insert rows otherwise you are going to overwrite
data in next row. I posted this solution in a newer posting.

"Rick Rothstein (MVP - VB)" wrote:

If Joel's guess if wrong, then for the example you posted, this macro
will
move the row of data to the column you specified...

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("Sheet1")
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

Rick


"J" wrote in message
...
I am importing CSV records from a sales management application and the
information, when imported, hits the sheet in the columns and each
range
needs to be moved into the correct columns. (This imported information
is
of
a different size each time it is imported. )

Also, there will be several ranges of records that will have to be
moved
under the same identified column.

Example:

move I2 thru M2 to D2
move N2 thru R2 to D3
move S2 thru W2 to D4 (and so on until it finds the last record with
the
same import code)

I have identified the columns that this information needs to be moved
into,
however I do not know the formula or code to tell it to do this?

Can anyone help me? Thanks, J.