2

Following a tutorial for arrays on VBA Excel. As you can see, just about everything is commented out and I still get this error. If I use Range("A1", "A1").Value = 1 there's no problem. I also noticed that the intelisense doesn't pick up 'Cells('

Option Explicit

Sub ArrayTest()

'Dim arrayint(1 To 5) As Integer
'Dim i As Integer
'Dim j As Integer


'    For j = 1 To UBound(arrayint)
'        arrayint(j) = 10 * j
'    Next j

'    For i = i To UBound(arrayint)
        Cells(1, 1).Value = 1 'arrayint(i)
'    Next i

End Sub
5
  • What version of Excel are you using? Where did you put this code (sheet, workbook, module, ...)? Commented Apr 6, 2014 at 3:47
  • Excel 2013. I tried it in sheet, workbook and module. I also tried it in a new excel and still nothing... Commented Apr 6, 2014 at 4:13
  • 1
    Try using Application then check if Intellisense pick up Cells property. So, in short, try this Application.Cells(1, 1).Value = 1. I have no way to test it at XL 2013, so give it a try. Commented Apr 6, 2014 at 4:40
  • @L42: Thanks !!! It all works now :D Is there a way to not have to use 'Application.' ? Update your answer and I'll mark it the best. Commented Apr 6, 2014 at 4:59
  • 2
    Well, basically it should work without explicitly using Application. I have no problem in it at XL 2010. Commented Apr 6, 2014 at 5:15

2 Answers 2

3

Try using Application and check if Intellisense picks up Cells property.
If so, replace your code by this:

Application.Cells(1, 1).Value = 1
Sign up to request clarification or add additional context in comments.

Comments

1

You have not commented the line

Cells(1, 1).Value = 1 'arrayint(i)

This may be the reason for error.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.