Thanks Thanks:  0
Likes Likes:  0
Results 1 to 5 of 5

Thread: Data Fill: easier way than this VBA?

  1. #1
    New Member
    Join Date
    Apr 2002
    Posts
    14
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    I am constantly adding rows to an Excel database, and I want to automatically number the records from 1 to x, x being last row. The code that follows works - but seems awkward because, since my data starts at row 6, I have to subtract 5 from the Row (function?). I thought that I could use .Count, but it didn't work. What is the command/function to count the total rows (not the row number) and then use it as a variable to auto fill to?

    Sub colfill()
    '
    ' colfill Macro
    ' Macro recorded 4/16/2002 by Preferred Customer
    '
    Range("a6") = 1
    RowCount = Range("b6").End(xlDown).Row - 5
    '
    Application.Goto Reference:="R6C1"
    Selection.DataSeries Rowcol:=xlColumns, Type:=xlLinear, Date:=xlDay, _
    Step:=1, Stop:=RowCount, Trend:=False
    End Sub

    Thanks, SJK

  2. #2
    MrExcel MVP
    Colo's Avatar
    Join Date
    Mar 2002
    Location
    Kobe, Japan
    Posts
    1,456
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    2 Thread(s)

    Default

    Hi sjk. Pls try this.

    Sub colfill()
    Range("A6").Value = 1
    Range("A6", Range("B65536").End(xlUp).Offset(, -1)).DataSeries 2, Step:=1
    End Sub

    Regards,
    Colo

  3. #3
    New Member
    Join Date
    Apr 2002
    Posts
    14
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Hi Colo: Yes, your program worked perfectly. I am trying to learn VBA and I am somewhat overwhelmed. Can I ask: did you know the solution just from experience, or did you look it up? I know that some basic ones can be built by using the Macro recorder. Thanks, SJK.

  4. #4
    MrExcel MVP
    Colo's Avatar
    Join Date
    Mar 2002
    Location
    Kobe, Japan
    Posts
    1,456
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    2 Thread(s)

    Default

    Hi sjk.
    I began to use "excel" since two years ago.Those days, I could only use the Macro recorder.
    There was no person using Excel around me.
    So, how to solve my problem was read the help and watched some web site.
    The persons who have own problem gather on bbs site.
    On the site, I could find the topic which could solve my problem.

    Regards,
    Colo

  5. #5
    New Member
    Join Date
    Apr 2002
    Posts
    14
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Hi Colo: Thanks for the advice. I am gradually learning. I agree: this site is very helpful. I have also found it helpful to take some programming language and go through it line by line, and even to re-enter the code. Sructures become familiar.. SJK


Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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