+ Reply to Thread
Results 1 to 2 of 2

Macros: Explaination on Logic for this Code?

  1. #1
    Registered User
    Join Date
    10-07-2005
    Posts
    2

    Macros: Explaination on Logic for this Code?

    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

  2. #2
    Forum Contributor
    Join Date
    11-11-2005
    Posts
    267
    Rye,

    Forget about your macro recording and tell us-clearly-what you want to do. Someone might be able to come up with a crisp code to help you. Then you can spend some time to study the logic of the solution code. You would learn better that way.
    HTH
    Myles

    ...constantly looking for the smoother pebble while the whole ocean of truth lies before me.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1