store a range

starl

Administrator
Joined
Aug 16, 2002
Messages
6,081
Office Version
  1. 365
Platform
  1. Windows
I need to store the values of a range to be placed at a later time.
What do I store them in? an array? So I need to create a loop to go through the range and place them in there???

thanks
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
store them for how long? Until the macro ends?

A STATIC variable will hold data while a DIMed variable has a limited life.

Please explain what you are trying to do.
 
Upvote 0
Well, the procedure will call other procedures, but ultimately it'll be the top procedure and the variables only need to last that long.

As to what I'm doing: I have a group of worksheets which will be deleted - but I need to store some information on those sheets to put in new sheets that will created.
Got a better idea? Sample code???? ANYTHING to make this easier :biggrin:
 
Upvote 0
Hey Starl,

You can create an array from a range easily:

MyData = Range("A2:Z1000").Value

Then, later you could use:
For i = 1 to UBound(MyData, 1)
For j = 1 to UBound(MyData, 2)
debug.Print MyData(i, j)
Next j
Next i

If you need to store the array, you can store the entire array in a workbook name:
Names.Add Name:="MyName", RefersTo:=MyData

Limits in Excel 2000 or earlier on storing a range in a name: 256 columns and not more than 5461 elements total. In XL2002 or later, the size is limited only by memory.

Credit to Bullen's "Excel 2002 VBA"

Bill
 
Upvote 0
MyData is of what type variable?
 
Upvote 0

Forum statistics

Threads
1,214,605
Messages
6,120,473
Members
448,967
Latest member
visheshkotha

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top