Can I make this shorter?

rutger

Board Regular
Joined
Apr 5, 2005
Messages
74
Hey there,
I was wondering if there's a way to make this code shorter?

Code:
    Cells(Target.Row, Target.Column + 2).Value = Target.Value
    Cells(Target.Row, Target.Column + 4).Value = Target.Value
    Cells(Target.Row, Target.Column + 6).Value = Target.Value
    Cells(Target.Row, Target.Column + 8).Value = Target.Value
    Cells(Target.Row, Target.Column + 10).Value = Target.Value
    Cells(Target.Row, Target.Column + 12).Value = Target.Value
    Cells(Target.Row, Target.Column + 14).Value = Target.Value
    Cells(Target.Row, Target.Column + 16).Value = Target.Value
    Cells(Target.Row, Target.Column + 18).Value = Target.Value
    Cells(Target.Row, Target.Column + 20).Value = Target.Value
    Cells(Target.Row, Target.Column + 22).Value = Target.Value
    Cells(Target.Row, Target.Column + 24).Value = Target.Value
    Cells(Target.Row, Target.Column + 26).Value = Target.Value
    Cells(Target.Row, Target.Column + 28).Value = Target.Value
    Cells(Target.Row, Target.Column + 30).Value = Target.Value
    Cells(Target.Row, Target.Column + 32).Value = Target.Value
    Cells(Target.Row, Target.Column + 34).Value = Target.Value
    Cells(Target.Row, Target.Column + 36).Value = Target.Value
    Cells(Target.Row, Target.Column + 38).Value = Target.Value

something like:

Cells(Target.Row, Target.Column +2, +4, etc.).value = Target.Value

Thanks in advance,
Rutger
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.

Andywiz

Board Regular
Joined
May 25, 2005
Messages
238
try this code:

Code:
Sub Loop_Step()

For n = 2 to 38 Step 2
  Cells(Target.Row, Target.Column + n).Value = Target.Value
Next n

End Sub

Hope this helps some,
Andy :eek:
 

rutger

Board Regular
Joined
Apr 5, 2005
Messages
74
Hey there Andy,

Thanks for the quick reply.
This does exactly what i had in mind.
Thanks again

Greetz,
Rutger
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,546
Messages
5,838,029
Members
430,526
Latest member
NiceGuyWithExcel2007

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
Top