Excel - Array to specific worksheet - nothing seems to work

Asked By dial13 on 03-Jun-12 01:29 PM
I have tried everything but the array stubbornly refuses to populate
any sheet except the one the code belongs to:

Sub WontChangeWorksheetDestination()

Dim wks As Worksheet
Set wks = Sheets(3)

With wks

Set TheRange = Range(Cells(1, 1), Cells(10, 10))
TheRange.Value = MyArray

End With

End sub

I have tried everything, but because the code is behind a button on
sheet 1 the array populates sheet 1 and does not seem to want to
populate any toher sheet no mattwer hw I try to qualify it ... what am
I missing?

Any help gratefully accepted,

Kind regards, Mark


isabelle replied to dial13 on 03-Jun-12 09:11 PM
hi dial13,

you missed the point ;-)

replace
Set TheRange = Range(Cells(1, 1), Cells(10, 10))

by
Set TheRange = .Range(.Cells(1, 1), .Cells(10, 10))


--
isabelle



Le 2012-06-03 13:29, dial13 a ?crit :
dial13 replied to isabelle on 03-Jun-12 09:23 PM
Hahaha thanks a lot, works like a dream:)