Purpose: Having a macro that adds a column and have it number all the rows then sorting the data. Trying to write a macro to delaminate a very complicated text file in multiple pieces, but that another piece of the puzzle.



Basically I recorded this and played it back and got a debugging error at the 5th line of the code:

ActiveCell.Offset(30698, -1).Range("A1:A34839").Select

The last data is on row 34,839. There are no gaps from row 1 to 34,839.

Where are they getting 30698 from?

2nd, How do you get the A34839 to be just the last item in that column in coding instead of a fixed range?

Sub Macro6()

'
Selection.EntireColumn.Insert
ActiveCell.FormulaR1C1 = "1"
ActiveCell.Offset(0, 1).Range("A1").Select
Selection.End(xlDown).Select
ActiveCell.Offset(30698, -1).Range("A1:A34839").Select
ActiveCell.Offset(0, -1).Range("A1").Activate
Selection.DataSeries Rowcol:=xlColumns, Type:=xlLinear, Date:=xlDay, _
Step:=1, Trend:=False
ActiveCell.Offset(30698, 0).Range("A1:B34839").Select
ActiveCell.Activate
Selection.Sort Key1:=ActiveCell.Offset(30698, 1).Range("A1"), Order1:= _
xlAscending, Header:=xlGuess, OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom
End Sub
===================

Using excel 97 w/window xp on a amd athlon XP processor. My cpu broke down the other day so I using a old laptop.

Thanks again everyone