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
 

Some videos you may like

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type

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
 

Watch MrExcel Video

Forum statistics

Threads
1,118,111
Messages
5,570,257
Members
412,313
Latest member
pauloalex
Top