Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
On 4/06/2012 3:32 AM, dial13 wrote:
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 Hi Not sure about your use of MyArray as you have not declared it, unless you have it Globally Declared somewhere else in your workbook. Try Dim wks As Worksheet Dim TheRange as Range Set wks = Sheets(3) Set TheRange = wks.Range(Cells(1, 1), Cells(10, 10)) with TheRange .Value = MyArray End With End Sub HTH Mick. |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
You need to link the Cells() statements back to the tarket worksheet.
Do not use "wks.range". Instead do this: range(wks.cells(1,1), wks.cells(10,10)) or with wks range(.cells(1,1), cells(10,10)) end with Without the link back to wks, Cells() will refer to the active worksheet only. And if you qualify Range with wks, that doesn't change what Cells() is referring to Robert Flanagan Add-ins.com LLC 144 Dewberry Drive Hockessin, Delaware, U.S. 19707 Phone: 302-234-9857, fax 302-234-9859 http://www.add-ins.com Productivity add-ins and downloadable books on VB macros for Excel On Jun 4, 7:36*am, Vacuum Sealed wrote: On 4/06/2012 3:32 AM, dial13 wrote: 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 Hi Not sure about your use of MyArray as you have not declared it, unless you have it Globally Declared somewhere else in your workbook. Try Dim wks As Worksheet Dim TheRange as Range Set wks = Sheets(3) Set TheRange = wks.Range(Cells(1, 1), Cells(10, 10)) with TheRange * * * * .Value = MyArray End With End Sub HTH Mick.- Hide quoted text - - Show quoted text - |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Stubborn cell formatting. | Excel Worksheet Functions | |||
Excel 2007 formatting wont change in column | Excel Discussion (Misc queries) | |||
change date formatting in destination cell | Excel Discussion (Misc queries) | |||
Date format from excel to CVS file wont. Change in CVS wont stay. | Excel Worksheet Functions | |||
HDI change paste options default to "Match Destination Formatting | Setting up and Configuration of Excel |