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

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
.Range("c16").Copy Destination:=.Range("c62")

is quick
 
Upvote 0

Forum statistics

Threads
1,223,248
Messages
6,171,027
Members
452,374
Latest member
keccles

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