+ Reply to Thread
Results 1 to 5 of 5

overflow error 6.. the macro just stops any idea why?

  1. #1
    ste mac
    Guest

    overflow error 6.. the macro just stops any idea why?

    Hi, the code below adds 1 thru' 14 in column 8 as long as there is
    a value in column 1, but it stops running at row 32767 with an overflow
    error l need it to carry on down to past row 60,000 is my machine not
    good enough? (I did not write the code)

    thanks for any help

    ste

    Sub add1to14()
    Application.ScreenUpdating = False
    Dim mrow As Integer, mvalue As Integer
    Range("a2").Select 'start at cell A1
    mvalue = 1
    Do Until ActiveCell.Value = ""
    mrow = ActiveCell.Row
    Cells(mrow, 8) = mvalue
    mvalue = mvalue + 1
    If mvalue > 14 Then mvalue = 1

    ActiveCell.Offset(1, 0).Range("A1").Select
    Loop
    Range("A1").Select
    Application.ScreenUpdating = True
    End Sub

  2. #2
    JulieD
    Guest

    Re: overflow error 6.. the macro just stops any idea why?

    Hi

    a variable with a data type of "integer" will store numbers up to 32767
    change
    dim mrow as integer
    to
    dim mrow as long

    and you might like to do the same for mvalue

    Cheers
    JulieD

    "ste mac" <[email protected]> wrote in message
    news:[email protected]...
    > Hi, the code below adds 1 thru' 14 in column 8 as long as there is
    > a value in column 1, but it stops running at row 32767 with an overflow
    > error l need it to carry on down to past row 60,000 is my machine not
    > good enough? (I did not write the code)
    >
    > thanks for any help
    >
    > ste
    >
    > Sub add1to14()
    > Application.ScreenUpdating = False
    > Dim mrow As Integer, mvalue As Integer
    > Range("a2").Select 'start at cell A1
    > mvalue = 1
    > Do Until ActiveCell.Value = ""
    > mrow = ActiveCell.Row
    > Cells(mrow, 8) = mvalue
    > mvalue = mvalue + 1
    > If mvalue > 14 Then mvalue = 1
    >
    > ActiveCell.Offset(1, 0).Range("A1").Select
    > Loop
    > Range("A1").Select
    > Application.ScreenUpdating = True
    > End Sub




  3. #3
    Chip Pearson
    Guest

    Re: overflow error 6.. the macro just stops any idea why?

    Integers are signed numeric variables that can store numbers
    between +/-32K. Use a Long instead of an Integer.


    --
    Cordially,
    Chip Pearson
    Microsoft MVP - Excel
    Pearson Software Consulting, LLC
    www.cpearson.com


    "ste mac" <[email protected]> wrote in message
    news:[email protected]...
    > Hi, the code below adds 1 thru' 14 in column 8 as long as there
    > is
    > a value in column 1, but it stops running at row 32767 with an
    > overflow
    > error l need it to carry on down to past row 60,000 is my
    > machine not
    > good enough? (I did not write the code)
    >
    > thanks for any help
    >
    > ste
    >
    > Sub add1to14()
    > Application.ScreenUpdating = False
    > Dim mrow As Integer, mvalue As Integer
    > Range("a2").Select 'start at cell A1
    > mvalue = 1
    > Do Until ActiveCell.Value = ""
    > mrow = ActiveCell.Row
    > Cells(mrow, 8) = mvalue
    > mvalue = mvalue + 1
    > If mvalue > 14 Then mvalue = 1
    >
    > ActiveCell.Offset(1, 0).Range("A1").Select
    > Loop
    > Range("A1").Select
    > Application.ScreenUpdating = True
    > End Sub




  4. #4
    ste mac
    Guest

    Re: overflow error 6.. the macro just stops any idea why?

    > Integers are signed numeric variables that can store numbers
    > between +/-32K. Use a Long instead of an Integer.


    Many thanks to Julie and Chip, back up and running again

    cheers to both

    ste

  5. #5
    JulieD
    Guest

    Re: overflow error 6.. the macro just stops any idea why?

    you're welcome

    "ste mac" <[email protected]> wrote in message
    news:[email protected]...
    >> Integers are signed numeric variables that can store numbers
    >> between +/-32K. Use a Long instead of an Integer.

    >
    > Many thanks to Julie and Chip, back up and running again
    >
    > cheers to both
    >
    > ste




+ 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