View Single Post
  #15   Report Post  
Posted to microsoft.public.excel.misc
JMay JMay is offline
external usenet poster
 
Posts: 468
Default I Need A Formula

Rick:

A final Thanks for all you've done (for me). My sudden problem with the R/T
9 overshadowed my thanking you for the added knowledge of the "JOIN".

Jim

"Rick Rothstein (MVP - VB)" wrote:

Rick - when I enter (as you suggest) the following (and step through), why
am
I getting R/T error 9 - Subscript out of range on line 4?

Sub Tester()
Dim Array1() As String
Dim Array2() As String
Array1(0) = "Jim"
Array1(1) = "Paul"
End Sub


You dimensioned Array1 as a dynamic array (no number between the
parentheses) and did not subsequently ReDim it before trying to assign
values to its elements. Somewhere, either in a Dim statement (in which case
the array will be fixed, not dynamic) or in a ReDim statement (for
dynamically declared arrays), you have to tell VB how many elements you plan
to assign data to (VB needs to set aside memory locations to store the data
that is going to be assigned later on in the program).

Rick