macro move cell with text one to right and one up!
Is this what you want
Public Sub ProcessData()
Dim LastRow As Long
Dim NumBreaks As Long
Dim IdxBreak As Long
Dim LastPos As Long
Dim i As Long
Dim j As Long
With ActiveSheet
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
For i = 1 To LastRow
NumBreaks = Len(.Cells(i, "A").Value) - Len(Replace(.Cells(i,
"A").Value, vbLf, ""))
IdxBreak = NumBreaks
LastPos = Len(.Cells(i, "A").Value)
For j = LastPos To 1 Step -1
If Mid$(.Cells(i, "A").Value, j, 1) = vbLf Then
.Cells(i, IdxBreak + 1).Value = Mid$(.Cells(i,
"A").Value, j + 1, LastPos - j)
LastPos = j - 1
IdxBreak = IdxBreak - 1
End If
Next j
.Cells(i, "A").Value = Left$(.Cells(i, "A").Value, LastPos)
Next i
End With
End Sub
--
__________________________________
HTH
Bob
"TooN" wrote in message
...
Hello,
I looked in the forum but could not find a good answer for my problem. I
have a sheet with a few hundred lines (download from SAP). The sheet has
the
following format:
A B
1 123456
321345
text
2 213453
894352
another text line
3 723467
831487
and another text line!
etc etc
I would like to have a macro that moves the cell that contains the text
one
cell to the right and one cell up!
With best regards
|