+ Reply to Thread
Results 1 to 4 of 4

Run time error 13, when VBA workbook opening in excel 2007

  1. #1
    Registered User
    Join Date
    03-16-2013
    Location
    NZ
    MS-Off Ver
    Excel 2010
    Posts
    2

    Run time error 13, when VBA workbook opening in excel 2007

    Hi there, I have the following VBA code which is running great in excel 2010, however when I am trying to ru the same vba in excel 2007 it pops up with Run time error 13 with the following row (highlighted in red and bold) becomes an issue.

    Can anyone please help?




    Range("F264").Select

    For x = 1 To 10000
    RW = ActiveCell.Row

    'ActiveCell.Offset(1, 0).Select

    'Get Position, Check for Date in the field, collect the values:
    'SD - Startdate, ED = End date, Mths = Months, Cost = Cost
    If ActiveCell.Row > 496 Then GoTo 200
    If IsDate(ActiveCell.Value) = True Then Else GoTo 100
    SD = ActiveCell.Offset(0, -1).Value
    ED = ActiveCell.Offset.Value
    Mths = ActiveCell.Offset(0, 1).Value
    COST = ActiveCell.Offset(0, 2).Value
    Scol = ActiveCell.Column

    'Position in the data range, and build the calculation based on dates
    'Firstly find the start:
    ActiveCell.Offset(0, 8).Activate
    For Y = 8 To 100
    If ActiveCell.Offset(-(RW - 260), 0).Value = ActiveCell.Offset(0, -Y).Value Then GoTo 50
    ActiveCell.Offset(0, 1).Select
    Next Y
    Cells(RW, 6).Select
    GoTo 100

    50:
    'Use the HLookup to set the values
    Ecol = ActiveCell.Column
    'Y = Y - 2
    ActiveCell.Offset(0, 2).Select
    For Z = 20 To (20 - Mths) + 1 Step -1
    ActiveCell.FormulaR1C1 = "=HLOOKUP(" & Z & ",R253C14:R255C33,2)*" & COST & "+ 1000*HLOOKUP(" & Z & ",R253C14:R256C33,3)"
    ActiveCell.Offset(0, -1).Select
    If ActiveCell.Column = 13 Then GoTo 100
    Next Z


    100:
    Cells(RW + 1, 6).Select
    Next x

  2. #2
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Run time error 13, when VBA workbook opening in excel 2007

    I reckon Mths probably doesn't contain a number. any error values in the sheet?

    please add code tags to your post too ;-)
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  3. #3
    Registered User
    Join Date
    03-16-2013
    Location
    NZ
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: Run time error 13, when VBA workbook opening in excel 2007

    Quote Originally Posted by JosephP View Post
    I reckon Mths probably doesn't contain a number. any error values in the sheet?

    please add code tags to your post too ;-)

    Hi Joseph, thanks for the feedback I will remember to add code tags next time.

    Assuming the Mths doesn't have a number, why will it work in excel 2010 but not 2007?

  4. #4
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Run time error 13, when VBA workbook opening in excel 2007

    it wouldn't-I assume that in 2010 the cell does contain a number. I reckon it's probably a formula that errors in 2007

+ 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