ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   write marco to put data from sheet to memory (https://www.excelbanter.com/excel-programming/272793-write-marco-put-data-sheet-memory.html)

Desmond Leung

write marco to put data from sheet to memory
 
Hi, I would like to write macro or dll
to copy a range of data from excel sheets to
memory so that I can recall these data from
other books or macros.
can anybody help me? Thanks

Patrick Molloy[_9_]

write marco to put data from sheet to memory
 
if you declare your variables as Public, they are
available so be used in other routines...


Option Explicit
Public Temp As Variant
Sub Main()
Call subFirst
Call subSecond
End Sub
Sub subFirst()
Dim x
x = Workbooks("Book1").Sheets("Sheet1").Range("A1:C7")
Temp = Workbooks("Book1").Sheets("Sheet1").Range
("A1:C7")
End Sub
Sub subSecond()
Workbooks("Book2").Sheets("Sheet1").Range("A1:C7") =
Temp
End Sub


Patrick Molloy
Microsoft Excel MVP

-----Original Message-----
Hi, I would like to write macro or dll
to copy a range of data from excel sheets to
memory so that I can recall these data from
other books or macros.
can anybody help me? Thanks
.


Desmond Leung

write marco to put data from sheet to memory
 
Hi, I tried to use these code, However, I need the
variable that can be
shared among different modules and different workbooks.
e.g, I have
written an addin workbook : addin.xla and I declared an
array called
arr1() as double.
then I use this array in other sheet to copy the values
into this array
from another workbook book1,xls and I find that it doesn't
work.

may you help me again? thanks


Desmond

-----Original Message-----
if you declare your variables as Public, they are
available so be used in other routines...


Option Explicit
Public Temp As Variant
Sub Main()
Call subFirst
Call subSecond
End Sub
Sub subFirst()
Dim x
x = Workbooks("Book1").Sheets("Sheet1").Range("A1:C7")
Temp = Workbooks("Book1").Sheets("Sheet1").Range
("A1:C7")
End Sub
Sub subSecond()
Workbooks("Book2").Sheets("Sheet1").Range("A1:C7") =
Temp
End Sub


Patrick Molloy
Microsoft Excel MVP

-----Original Message-----
Hi, I would like to write macro or dll
to copy a range of data from excel sheets to
memory so that I can recall these data from
other books or macros.
can anybody help me? Thanks
.

.


Desmond Leung

write marco to put data from sheet to memory
 
Hi, I tried to use these code, However, I need the variable that can be
shared among different modules and different workbooks. e.g, I have
written an addin workbook : addin.xla and I declared an array called
arr1() as double.
then I use this array in other sheet to copy the values into this array
from another workbook book1,xls and I find that it doesn't work.

may you help me again? thanks


Desmond

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


All times are GMT +1. The time now is 03:41 PM.

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