View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Help with this code

Cells() refers to the activesheet. If S isn't the activesheet, then kablewie!!!

Set theRange = s.Range(Cells(1, c), Cells(UBound(myArray), c))
could be
Set theRange = s.Range(s.Cells(1, c), s.Cells(UBound(myArray), c))

or

with s
Set theRange = .Range(.Cells(1, c), .Cells(UBound(myArray), c))
end with

The dots mean that that thing belongs to the previous With object.

matelot wrote:

I must be blind. Please help me find what's the problem with this code.
I get the following error when I run it.
"Run-Time error 1004: Application-defined or object-defined error"
My code is really simple and yet I don't know what's wrong with it.

Dim myArray(1,1) as string
c= 1
set s = workbooks("test.xls").sheets(2)
Set theRange = s.Range(Cells(1, c), Cells(UBound(myArray), c)) <-run time
error on this line

Please help.


--

Dave Peterson