Let's do real programming:

agouveia

New Member
Joined
Sep 9, 2014
Messages
5
Help me make this Piece of VBA into something a little more elegant?

I'm envisioning something like:

Sub

Define

rows=(62,108,154,200)

//Notes
i=Row
j=Column
//

i = 16
j = 3

[FONT=wf_segoe-ui_normal, Segoe UI, Segoe WP, Tahoma, Arial, sans-serif]Cell(i,j).Select
Selection.Copy
For i=rows
Cell(i,j).Select
ActiveSheet.Paste

Endsub


INSTEAD OF THIS:
[/FONT]Range("C16").Select
Selection.Copy
Range("C62").Select
ActiveSheet.Paste
Range("C108").Select
ActiveSheet.Paste
Range("C154").Select
ActiveSheet.Paste
Range("C200").Select
ActiveSheet.Paste
Range("C246").Select
ActiveSheet.Paste
Range("C292").Select
ActiveSheet.Paste
[FONT=wf_segoe-ui_normal, Segoe UI, Segoe WP, Tahoma, Arial, sans-serif]
[/FONT]
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
.Range("c16").Copy Destination:=.Range("c62")

is quick
 
Upvote 0

Forum statistics

Threads
1,226,730
Messages
6,192,702
Members
453,748
Latest member
akhtarf3

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