I'm creating an array P & want to dump it's elements into an Excel worksheet :

VB Code:
  1. Set oXLApp = New Excel.Application
  2. Set oXLBook = oXLApp.Workbooks.Add
  3. Set oXLSheet = oXLBook.Worksheets(1)
  4.  
  5. While param < Val(Text3.Text)
  6. param = Val(Text2.Text) + Val(Text4.Text) * m
  7. ...
  8. oXLSheet.Cells(m + 1, 1).Value = param
  9. ...
  10. m = m+ 1
  11. Wend
  12. ...
  13. End Sub

I get a 'object variable or with block variable not set' error on statement :
oXLSheet.Cells(m + 1, 1).Value = param
Why?
I thought I created the oXLSheet object in the statement before the While loop : Set oXLSheet = oXLBook.Worksheets(1)
Does this not carry over into a loop ?!