Click here to Skip to main content
15,895,557 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I use the following code in Excel VBA to copy a Excel sheet for calculation:
VB
Dim Store1Sheet() As Varient
Store1Sheet = Range("A1:D99")

Please would you adivse how to copy several Excel sheets to 1 variant, says StoreMultiSheet.

Many thanks.
____________________________________
I find the solution as follow:

Dim StoreMultiSheet(1 to 10) As Varient
Dim SheetNo As Integer

For SheetNo = 1 to 10
StoreMultiSheet(SheetNo) = Worksheets(SheetNo).UsedRange
Next SheetNo
Posted
Updated 29-Aug-12 5:30am
v3
Comments
Kenneth Haugland 28-Aug-12 13:43pm    
MEaning 1 workbook with one sheet collected from different sheets, or just one workbook with multiple sheets?

1 solution

In your code you don't "copy an Excel Sheet" to one variable!
These command's mean:
VB
Dim Store1Sheet() As Variant 'declare variable, array of Variants
Store1Sheet = Range("A1:D99") ' set variable, type of object: array of Excel.Range


I'm not sure what you want to do...
Please, be more specific, improve your question and i'll try to upgrade my answer.

More about MS Excel objects: http://msdn.microsoft.com/en-us/library/office/aa209782%28v=office.10%29.aspx[^]
More about MS Visual Basic Reference: http://msdn.microsoft.com/en-us/library/office/aa269683%28v=office.10%29[^]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900