View Single Post
  #6   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 tohave stopped working!

On Sunday, 20 April 2014 20:22:57 UTC+7, Cimjet wrote:
Hi Mark

I'm no VBA expert and I'm using XL2003 but your script is okay. Close that workbook.

Open a new Workbook and try it again.

Sub test() ' This should select the range(array)

Dim MyVar As Variant

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

End Sub

or

Sub test()

Dim MyVar As Variant ' This will copy your array

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

Range("M1:W27") = MyVar

End Sub



I never copied this way before !!! but it works.

The problem could be what you are trying to do with the variable.

It's Easter Sunday morning and I'm leaving but I'm sure someone else will be able to help if you don't find the problem first.

You've got one wheel stock in the mud and going in circle.

Close everything and clear your mind.

It does wonders

Happy Easter

John


Hi guys, thanks for all your inputs, apologies I had to run shortly after posting this so never got chance to follow up and in the end I 'spit out the dummy' and sued the code I had before that was working (I got a bee in my bonnet about it and was trying to replace 12 lines that worked with 2 lines that turned out not to. I will check it out, out of courtesy (and I might even learn something!) but I should learn to leave well alone when something is working as my goal is not to become the world's most knowledgeable excel VBA programmer nor to write the world's most elegant and compact code, I should learn that saving a nanosecond (literally) of time in some code that works perfectly well is more a signal I have psychological problems than it is that I need o solve a problem, so in short, thanks to all and apologies to all as always I really appreciate everyone's time and concern and input.

Kind regards, Mark