ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Compile error HELP (https://www.excelbanter.com/excel-programming/355377-compile-error-help.html)

Jim May

Compile error HELP
 
Trying to understand more about arrays,,
I have values in cells A11:A19, so when I run:

Sub CreateAnArray()
Dim MyArray(9) As Long
Dim i As Integer
Dim R As Range
i = 0
Set R = Range("A11:A19")
For Each c In R
MyArray(i).Value = c.Value ' Bombing Here Compile error!!
i = i + 1
Next c
End Sub


WHY?
Thanks,,



Dave Peterson

Compile error HELP
 
Option Explicit
Sub CreateAnArray()
Dim MyArray(9) As Long
Dim i As Integer
Dim R As Range
Dim C As Range
i = 0
Set R = Range("A11:A19")
For Each C In R
MyArray(i) = C.Value ' Bombing Here Compile error!!
i = i + 1
Next C
End Sub



Jim May wrote:

Trying to understand more about arrays,,
I have values in cells A11:A19, so when I run:

Sub CreateAnArray()
Dim MyArray(9) As Long
Dim i As Integer
Dim R As Range
i = 0
Set R = Range("A11:A19")
For Each c In R
MyArray(i).Value = c.Value ' Bombing Here Compile error!!
i = i + 1
Next c
End Sub

WHY?
Thanks,,


--

Dave Peterson


All times are GMT +1. The time now is 03:05 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com