View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Trevor Shuttleworth Trevor Shuttleworth is offline
external usenet poster
 
Posts: 1,089
Default Setting a range?

Works for me.

What values do you get for EndRow and EndCol ?

What error message do you get ?

Regards

Trevor


"jayklmno" wrote in message
...
What is wrong with this code?

Dim MyArray As Variant
Dim MyRange As Range
Dim EndRow As Long
Dim EndCol As Integer

Debug.Print Sheets("Data").Range("A1")
EndRow = Sheets("Data").Range("A1").End(xlDown).Row
EndCol = Sheets("Data").Range("A1").End(xlToRight).Column

Set MyRange = Worksheets("Data").Range(Cells(1, 1), Cells(EndRow, EndCol))
MyArray = MyRange

The Set MyRange line errors out with an Runtime Error. EndRow and EndCol
are
valid locations, so it has to be how I use the cells in the range
statement?
Any help?