View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Mark Stephens Mark Stephens is offline
external usenet poster
 
Posts: 124
Default Where am I going wrong? Cells reference to a range appears to havestopped working!

Hi,

This one is really puzzling me as it seems pretty basic but obviously (unless VBA in excel 2013 has stopped supporting it which is unlikely) I am doing something wrong.

I am actually trying to assign a range to an array like so:

Dim MyVar as variant
MyVar = ActiveWorkbook.Sheets(1).Range(Cells(1, 1), Cells(27, 11))

For some strange reason it will not do the allocation.

I thought that maybe I had gotten the reference notation wrong so I tried the following to test it:

ActiveWorkbook.Sheets(1).Range(Cells(1, 1), Cells(27, 11)).Select

Lo and behold that wont work either, which suggests that's the problem.

However I have looked up the notation to check, and even pasted an example from Microsoft into my code to test and that wont work either, which suggests it may be something else but I am at a complete loss to know what that something else might be. Can anyone either see anything wrong with the code above or if not suggest what is wrong/why it isn't working?

Any help much appreciated, it's almost embarrassing to be asking such a simple thing but I've tried everything I can to fix it and it has held me up for long enough so I thought someone on the user group may be able to help me.

Thanks in advance, Mark