Share via

Run-time Error '13'

santi 1 Reputation point
Nov 22, 2021, 3:15 PM

Hi guys,

Could you help me with this error ? I'm a bit lost ..

Thx a lot,
Santi


Sub Actualisatie()

Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = False
Dim i As Integer
i = 0

'STEP 1. CALCULATE OT FOR EACH PROJECT PERIOD

    Range("Scenario").Value = i


    Do While i <= Range("subs_period").Value

        Application.StatusBar = "Actualisation (VEA-Model): Goalseek OT in year " & i

        Range("Scenario").Value = i
        Call Goalseek
        Range("OT_Start").Offset(0, i).Value = Range("GS_OT_PF_GS").Value
        i = i + 1

        Application.StatusBar = False

 Loop

'STEP 2. RETURN TO START PERIOD

 'Range("SCenario").Value = 0
    'Call Goalseek

End Sub

VB
VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,799 questions
Office Visual Basic for Applications
Office Visual Basic for Applications
Office: A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.Visual Basic for Applications: An implementation of Visual Basic that is built into Microsoft products.
1,501 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Michael Taylor 57,216 Reputation points
    Nov 22, 2021, 4:17 PM

    Given just VB and runtime error 13 it looks like a type issue but it isn't clear. Could you provide some more information as it is really hard to just look at your code and figure things out?

    1. What line is generating the runtime error?
    2. This looks like an Excel spreadsheet code, are you calling this from within an Excel macro or via an app that is talking to Excel using interop?
    3. Can you provide a sample set of data in your spreadsheet including the column information so we can try to replicate the issue?

    Just on a guess I'm going to assume the range you're passing to this code is bad. Especially around that Scenario column. But this is a total guess at this point.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.