I am a relative beginner at writing macros, self taught but enthusiastic. I would appreciate any help you could offer with my coding problem.
Attached is a simple macro to illustrate my problem.
The macro code, amongst other things, enters data from a row into a column.
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com
ffice
ffice" /><o
> </o
>
The value in the first cell entered manually.
Then the macro, (lines 4-33) auto fills the range C20:R20, and cuts and pastes
the individual cells values in row 20 into the column C.
As further data is entered into row 20, it is copied into column C
<o
> </o
>
Even in this simple example this action generates 29 lines of repetitive code, and lots of opportunities for errors.
<o
> </o
>
Is there any way of condensing these 29 lines of code, and achieve the same result?
Any assistance would be gratefully received.
<o
> </o
>
Thank you,
Don.
Attached is a simple macro to illustrate my problem.
The macro code, amongst other things, enters data from a row into a column.
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com




The value in the first cell entered manually.
Then the macro, (lines 4-33) auto fills the range C20:R20, and cuts and pastes
the individual cells values in row 20 into the column C.
As further data is entered into row 20, it is copied into column C
<o


Even in this simple example this action generates 29 lines of repetitive code, and lots of opportunities for errors.
<o


Is there any way of condensing these 29 lines of code, and achieve the same result?
Any assistance would be gratefully received.
<o


Thank you,
Don.
Code:
Sub DOUBLE_ENTRY_TRIAL()<o:p></o:p>
'<o:p></o:p>
' DOUBLE_ENTRY_TRIAL Macro<o:p></o:p>
' Macro recorded <?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" /><st1:date Month="5" Day="25" Year="2012">25/05/2012</st1:date> by Don<o:p></o:p>
'<o:p></o:p>
<o:p> </o:p>
'<o:p></o:p>
Range("C20").Select<o:p></o:p>
Selection.AutoFill Destination:=Range("C20:R20"), Type:=xlFillDefault<o:p></o:p>
Range("C20:R20").Select<o:p></o:p>
Range("D20").Select<o:p></o:p>
Selection.Cut Destination:=Range("C21")<o:p></o:p>
Range("E20").Select<o:p></o:p>
Selection.Cut Destination:=Range("C22")<o:p></o:p>
Range("F20").Select<o:p></o:p>
Selection.Cut Destination:=Range("C23")<o:p></o:p>
Range("G20").Select<o:p></o:p>
Selection.Cut Destination:=Range("C24")<o:p></o:p>
Range("H20").Select<o:p></o:p>
Selection.Cut Destination:=Range("C25")<o:p></o:p>
Range("I20").Select<o:p></o:p>
Selection.Cut Destination:=Range("C26")<o:p></o:p>
Range("J20").Select
Selection.Cut Destination:=Range("C27")<o:p></o:p>
Range("K20").Select<o:p></o:p>
Selection.Cut Destination:=Range("C28")<o:p></o:p>
Range("L20").Select<o:p></o:p>
Selection.Cut Destination:=Range("C29")<o:p></o:p>
Range("M20").Select<o:p></o:p>
Selection.Cut Destination:=Range("C30")<o:p></o:p>
Range("N20").Select<o:p></o:p>
Selection.Cut Destination:=Range("C31")<o:p></o:p>
Range("O20").Select<o:p></o:p>
Selection.Cut Destination:=Range("C32")<o:p></o:p>
Range("P20").Select<o:p></o:p>
Selection.Cut Destination:=Range("C33")<o:p></o:p>
Range("Q20").Select<o:p></o:p>
Selection.Cut Destination:=Range("C34")<o:p></o:p>
Range("R20").Select<o:p></o:p>
Selection.Cut Destination:=Range("C35")<o:p></o:p>
Range("D20").Select<o:p></o:p>
ActiveCell.FormulaR1C1 = "=R[-1]C-RC[-1]"<o:p></o:p>
Range("D20").Select<o:p></o:p>
Selection.AutoFill Destination:=Range("D20:D35"), Type:=xlFillDefault<o:p></o:p>
Range("D20:D35").Select<o:p></o:p>
Range("I31").Select<o:p></o:p>
End Sub