Using a Variable to Copy a Range

Lorgach

New Member
Joined
Jul 6, 2005
Messages
16
Hi All,
Is there a way to get a Variable or Object to hold all the Data including the Formatting in a specified Range so it can be used at various stages during a Macro in order to do a similar action to Copy and Paste.

Something like:

VariableName = Range("A1")

Range("B2") = VariableName

I know that this is like copying only the Data from one Cell to the other, but the Variable can hold this Data so it can be used to input it to various Cells at various times during the execution of the Macro without having to re-select the target Cell Range each time.

I need something to hold the Data and Formatting of a large Range like Range(“A1:F15”) for use in the Macro.
At the moment I use the Copy and Paste method but this just seems very cumbersome compared to using some kind of Variable.

Thanks in advance for any suggestions.
Jim
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
A Range Object would hold the data and the formatting, but you would need to access the relevant properties to copy them to another range. You can't assign the entire object to another object. In your example it's the (default) Value property that's being assigned.
 
Upvote 0

Forum statistics

Threads
1,214,642
Messages
6,120,698
Members
448,979
Latest member
DET4492

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