Run-time error "9" Subscript out of range ---- please help

aatel

New Member
Joined
Jun 19, 2015
Messages
8
Hi I am new to excel vb.
I am trying to import some values from one software (STAAD.Pro), to excel. It works for small quantity. But when the no of values are more, means number of items are more, it shows the error Runtime error - 9, subscript out of range.
But for small quantity of numbers it works perfectly.


******
The code I used is given below.
I suspect the problem with array. It may be problem with array stack overflow? Or it may be problem due to not defining delimit or ubound?
I dont know how to use ubound or delimit also.
Could anyone suggest me, how it can be resolved.
******
Please help.............



Private Sub CommandButton1_Click()
Dim objOpenSTAAD As Object
Dim supp_Scount As Long
Dim supp_nodes() As Long
Dim loadcase As Long
Dim loadcase1 As Long
Dim loadcase2 As Long
Dim Noloadcase As Long
Dim dReactionArray(0 To 10) As Double
Dim Scount As Long
Dim Scount1 As Long
Dim LCScount As Long
'Dim strstring
''strstring = "Ubound of arrdReactionArray is :" & UBound(arrdReactionArray)
'MsgBox strstring
' opening staad file
Set objOpenSTAAD = GetObject(, "StaadPro_OpenSTAAD")
' first load case
loadcase1 = Cells(4, 14).Value
' second load case
loadcase2 = Cells(5, 14).Value
' no of load cases
Noloadcase = Cells(5, 14).Value - Cells(4, 14).Value + 1
' no of supports from staad file
supp_count = objOpenSTAAD.Support.GetSupportcount
' defining no of support nodes
ReDim supp_nodes(0 To (supp_count - 1)) As Long
' get support nodes
objOpenSTAAD.Support.GetSupportNodes supp_nodes
' 1 to no of supports in staad
' for each load case
' load case
For Scount = 1 To supp_count


Cells(3 + (Scount - 1) * Noloadcase, 1).Value = supp_nodes(Scount - 1)

' For LCScount = 1 To Noloadcase

For loadcase = loadcase1 To loadcase2
Cells(3 + (Scount - 1) * Noloadcase + loadcase - 100, 2).Value = loadcase

For Scount1 = 1 To 6
objOpenSTAAD.Output.GetSupportReactions supp_nodes(Scount - 1 + loadcase - loadcase1), loadcase, dReactionArray
Cells(3 + (Scount - 1) * Noloadcase + loadcase - 100, Scount1 + 2).Value = dReactionArray(Scount1 - 1)
Next
Next
Next
'Next

Set objOpenSTAAD = Nothing
End Sub
 
Output.GetSupportReactions

Returns support reactions for the node number and load case specified.

VB Syntax

Output.GetSupportReactions
NodeNo, LoadCase, ReactionArray

Where:

NodeNo

Long variable contains the node number, which is supported.

LoadCase

Long variable contains the load case number.

ReactionArray

A long array of dimension 6, which returns support reactions.

VB Example

'Get the application object --

'Get Support Reaction

objOpenSTAAD.Output.GetSupportReactions (lNodeNo, lLoadCase,

dReactionArray)
 
Upvote 0

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.

Forum statistics

Threads
1,214,601
Messages
6,120,460
Members
448,965
Latest member
grijken

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top