• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Static Array - Subscript out of range - using Selection

Instigator81

New Member
I am trying to create a simple static array that is the size of my Selection. I selected 4 cells when I ran the code below and it throws the error, "subscript out of range" on "SelectedRange(i, 1) = 1", when i = 1. I'm sure I'm making a simple mistake, any ideas?


Dim SelectedRange() As Variant

ReDim SelectedRanged(1 To Selection.Cells.Count, 1 To 3) As Variant

Dim i As Integer


For Each c In Selection.Cells

i = i + 1

SelectedRange(i, 1) = 1

SelectedRange(i, 2) = 2

SelectedRange(i, 3) = "awesome"

Next c
 
Back
Top