ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Array to specific worksheet - nothing seems to work (https://www.excelbanter.com/excel-programming/446228-array-specific-worksheet-nothing-seems-work.html)

dial13[_2_]

Array to specific worksheet - nothing seems to work
 
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've tried everything, but because the code is behind a button on
sheet 1 the array populates sheet 1 and doesn't 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

Array to specific worksheet - nothing seems to work
 
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 :
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


dial13[_2_]

Array to specific worksheet - nothing seems to work
 
Hahaha thanks a lot, works like a dream:)



On Monday, June 4, 2012 9:11:40 AM UTC+8, isabelle wrote:
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 :
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




All times are GMT +1. The time now is 12:31 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com