Consulting

Results 1 to 3 of 3

Thread: Solved: can anyone see what's wrong with this?

  1. #1

    Solved: can anyone see what's wrong with this?

    [vba]Option Explicit
    Sub Main()
    Dim MyArray(1 To 12) As Integer
    Dim i As Variant
    Dim n As Variant
    n = Sheets("Analysis").Range("A1").Value
    For i = 0 To n
    MyArray(i) = Sheets("Analysis").Cells(22, i + 7).Value
    Next i
    End Sub[/vba]



    edit: the error highlights the MyArray line, saying there is an invalid range
    Last edited by Aussiebear; 07-17-2009 at 03:05 PM. Reason: Added VBA tags to code

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    You have declared thearray as 1 To 12 and are then trying to load item 0, which just ain't there.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    thanks!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •