+ Reply to Thread
Results 1 to 3 of 3

generate sequence of number

  1. #1
    cyzax7 via OfficeKB.com
    Guest

    generate sequence of number

    hello there,

    I have prob with my code that need your guide. I want to create a macro that
    will generate numbers starting from 0 to 6 000 000 000 in Column A when user
    click on the command button(Generate_Numbers). The numbers are in multiple of
    50000. Below are the code: When I tried to debug the code, a message box
    displayed showing a run time error.. Can someone show me where is the
    mistakes ??

    Sub Generate_Numbers()
    Dim CountRow As Integer
    Dim i As Double


    For CountRow = 2 To cLastRow = 120000
    i = 0
    Worksheets("Data2").Cells(CountRow, "A").Value = i
    i = i + 500000
    CountRow = CountRow + 1
    Next CountRow

    End Sub

    ********Generate numbers command button in Worksheet ("Data2")
    ****************

    Private Sub GenerateNumCommandButton1_Click()
    Generate_Numbers
    End Sub

    **************************************************************************


    tq

    --
    Message posted via OfficeKB.com
    http://www.officekb.com/Uwe/Forums.a...mming/200606/1

  2. #2
    RB Smissaert
    Guest

    Re: generate sequence of number

    You want something like this:

    Sub Generate_Numbers()

    Dim CountRow As Long
    Dim cLastRow As Long
    Dim i As Double

    cLastRow = 100

    For CountRow = 2 To cLastRow
    Worksheets("Data2").Cells(CountRow, 1).Value = i
    i = i + 500000
    Next CountRow

    End Sub


    RBS


    "cyzax7 via OfficeKB.com" <u22797@uwe> wrote in message
    news:6215602f43b9f@uwe...
    > hello there,
    >
    > I have prob with my code that need your guide. I want to create a macro
    > that
    > will generate numbers starting from 0 to 6 000 000 000 in Column A when
    > user
    > click on the command button(Generate_Numbers). The numbers are in multiple
    > of
    > 50000. Below are the code: When I tried to debug the code, a message box
    > displayed showing a run time error.. Can someone show me where is the
    > mistakes ??
    >
    > Sub Generate_Numbers()
    > Dim CountRow As Integer
    > Dim i As Double
    >
    >
    > For CountRow = 2 To cLastRow = 120000
    > i = 0
    > Worksheets("Data2").Cells(CountRow, "A").Value = i
    > i = i + 500000
    > CountRow = CountRow + 1
    > Next CountRow
    >
    > End Sub
    >
    > ********Generate numbers command button in Worksheet ("Data2")
    > ****************
    >
    > Private Sub GenerateNumCommandButton1_Click()
    > Generate_Numbers
    > End Sub
    >
    > **************************************************************************
    >
    >
    > tq
    >
    > --
    > Message posted via OfficeKB.com
    > http://www.officekb.com/Uwe/Forums.a...mming/200606/1



  3. #3
    cyzax7 via OfficeKB.com
    Guest

    Re: generate sequence of number

    Hi RB Smissaert,

    Thanxs.. It works so well ;>


    RB Smissaert wrote:
    >You want something like this:
    >
    >Sub Generate_Numbers()
    >
    > Dim CountRow As Long
    > Dim cLastRow As Long
    > Dim i As Double
    >
    > cLastRow = 100
    >
    > For CountRow = 2 To cLastRow
    > Worksheets("Data2").Cells(CountRow, 1).Value = i
    > i = i + 500000
    > Next CountRow
    >
    >End Sub
    >
    >RBS
    >
    >> hello there,
    >>

    >[quoted text clipped - 31 lines]
    >>
    >> tq


    --
    Message posted via OfficeKB.com
    http://www.officekb.com/Uwe/Forums.a...mming/200606/1

+ 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