In case it helps, the single line database looks like the following:
Date: 123
Name: 456
Shift: 789
Category A
line 1
line 2
line 3
line 4
line 5
Category B
line 1
line 2
line 3
line 4
line 5
line 6
Date: 123
Name: 456
Shift: 789
Category A
line 1
line 2
line 3
line 4
line 5
Category B
line 1
line 2
line 3
line 4
line 5
line 6
"StumpedAgain" wrote:
> I have the following program to translate a single-column database into a
> matrix with five columns. I get an error on the line:
>
> startspot.Offset(1, 0) = Right(startspot.Offset(0, 0).Value,
> Len(startspot.Value) - 6)
>
> I'm not sure what the problem is. I've tried re-arranging and doing some
> different things, but can't figure it out. Any thoughts?
>
> Thanks!
>
> Mind text wrapping:
>
> Option Explicit
> Sub Save_Time()
>
> Dim glcount, j, m, n As Integer
> Dim startspot, nextspot As Range
>
> j = 0
>
> Set startspot = Range("A1") 'or wherever you start
> Set nextspot = Range("A1")
>
> Do
> Set startspot = startspot.Offset(j, 0)
> If nextspot = "" Then Exit Do
> nextspot.Select
> ActiveCell.Offset(1, 0).Cut Destination:=startspot.Offset(0, 1)
> ActiveCell.Offset(0, 0).Cut Destination:=startspot.Offset(0, 0)
> ActiveCell.Offset(2, 0).Cut Destination:=startspot.Offset(0, 2)
> startspot.Offset(1, 1).Value = Right(startspot.Offset(0, 1).Value,
> Len(startspot.Value) - 6)
> startspot.Offset(1, 0) = Right(startspot.Offset(0, 0).Value,
> Len(startspot.Value) - 6)
> startspot.Value = Left(startspot.Value, 4)
> startspot.Offset(0, 1).Value = Left(startspot.Offset(0, 1).Value, 4)
> startspot.Offset(1, 2).Value = Right(startspot.Offset(0, 2).Value,
> Len(startspot.Offset(0, 2).Value) - 7)
> startspot.Offset(0, 2).Value = Left(startspot.Offset(0, 2).Value, 5)
>
> Set nextspot = ActiveCell.Offset(4, 0)
> nextspot.Select
> Set nextspot = ActiveCell.End(xlDown).Offset(2, 0)
>
> With ActiveCell
> m = Range(.Offset(0, 0), .End(xlDown)).Rows.Count
> End With
>
> ActiveCell.Resize(m, 1).Select
> Selection.Cut Destination:=startspot.Offset(0, 3)
>
> nextspot.Select
> Set nextspot = ActiveCell.End(xlDown).Offset(2, 0)
>
> With ActiveCell
> n = Range(.Offset(0, 0), .End(xlDown)).Rows.Count
> End With
>
> ActiveCell.Resize(n, 1).Select
> Selection.Cut Destination:=startspot.Offset(0, 4)
>
> j = j + Application.Max(n, m)
>
> Loop
>
> End Sub
>