Variables to Optimize VBA Macro

valverde311

New Member
Joined
Apr 4, 2011
Messages
4
Hi all,

I wrote a lengthy macro that copies a number of cells from one workbook to another and I reference the cells via the syntax below....

Since I'm constantly repeating the bold portion, I'm wondering if setting a variable = to the bold portion would speed things up.


Workbooks("Master File.xls").Sheets(1).Cells(71, 4).Value =



Both a) and b) were not working when I tried...



a) Dim Master as String
b) Dim Master as Worksheets

Set Master = Workbooks("Master File.xls").Sheets(1)







Can anyone help?
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Use the second one but remove the s after Worksheet.
 
Upvote 0
Hallo

Sure you can improve the code, you can better describe the commands that you want to improve with a practical example?
There may be several solutions to your question
How many cells are involved, which cycle you get

Pending greetings
 
Upvote 0
Meant to add - using a variable such as this might not speed the code up.

What it'll definitely do is make the code easier to follow and that might help in pinpointing anything that's slowing things down.
 
Upvote 0

Forum statistics

Threads
1,224,592
Messages
6,179,777
Members
452,942
Latest member
VijayNewtoExcel

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