Macro/Repetitive steps in excel

%3CLINGO-SUB%20id%3D%22lingo-sub-3028509%22%20slang%3D%22en-US%22%3EMacro%2FRepetitive%20steps%20in%20excel%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3028509%22%20slang%3D%22en-US%22%3E%3CP%3EIs%20there%20a%20way%20create%20a%20macro%20to%20do%20repetitive%20steps%20for%20moving%20data%20from%20column%20A%20rows%201-10%20to%20row%201%20columns%20A-J%20then%20move%20down%20line%2011%20and%20do%20the%20same%20thing%20for%20rows%2011-20%20into%20columns%20A-J%20row%2011%20without%20having%20to%20edit%20the%20Macro%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-3028509%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3028891%22%20slang%3D%22en-US%22%3ERe%3A%20Macro%2FRepetitive%20steps%20in%20excel%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3028891%22%20slang%3D%22en-US%22%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-visual-basic%22%3E%3CCODE%3ESub%20TransposeData()%0A%20%20%20%20Dim%20r%20As%20Long%0A%20%20%20%20Dim%20m%20As%20Long%0A%20%20%20%20Dim%20c%20As%20Long%0A%20%20%20%20Application.ScreenUpdating%20%3D%20False%0A%20%20%20%20m%20%3D%20Cells(Rows.Count%2C%201).End(xlUp).Row%0A%20%20%20%20For%20r%20%3D%204%20To%20m%20Step%2010%0A%20%20%20%20%20%20%20%20For%20c%20%3D%204%20To%2011%0A%20%20%20%20%20%20%20%20%20%20%20%20If%20Cells(r%20%2B%20c%20-%204%2C%203).Value%20%26lt%3B%26gt%3B%20%22%22%20Then%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20Cells(r%20-%202%2C%20c).Value%20%3D%20Cells(r%20%2B%20c%20-%204%2C%203).Value%0A%20%20%20%20%20%20%20%20%20%20%20%20End%20If%0A%20%20%20%20%20%20%20%20Next%20c%0A%20%20%20%20Next%20r%0A%20%20%20%20Application.ScreenUpdating%20%3D%20True%0AEnd%20Sub%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1237058%22%20target%3D%22_blank%22%3E%40darylpaul%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional Visitor

Is there a way create a macro to do repetitive steps for moving data from column A rows 1-10 to row 1 columns A-J then move down line 11 and do the same thing for rows 11-20 into columns A-J row 11 without having to edit the Macro?

1 Reply

 

Sub TransposeData()
    Dim r As Long
    Dim m As Long
    Dim c As Long
    Application.ScreenUpdating = False
    m = Cells(Rows.Count, 1).End(xlUp).Row
    For r = 4 To m Step 10
        For c = 4 To 11
            If Cells(r + c - 4, 3).Value <> "" Then
                Cells(r - 2, c).Value = Cells(r + c - 4, 3).Value
            End If
        Next c
    Next r
    Application.ScreenUpdating = True
End Sub

@darylpaul