Insert rows and copy transpose

PMARI

New Member
Joined
Jun 10, 2011
Messages
42
Dear All,

My requirement as given below,

Having XL sheet with Name and four address columns.

Need to insert 4 rows below each name and respective copy 4 address cells and paste (Transpose ) below name.
Repeat this action till entry in col ”A”

Name
Add1
Add2
Add3
Add4
AAAAA
Add1
Add2
Add3
Add4
BBBB
Add1
Add2
Add3
Add4
Base File

<tbody>
</tbody>

Name
Add1
Add2
Add3
Add4
AAAAA
Add1
Add2
Add3
Add4
Add1




Add2




Add3




Add4




BBBB
Add1
Add2
Add3
Add4
Add1




Add2




Add3




Add4





My Macro

' Macro4 Macro
'


'
Rows("3:6").Select
Selection.Insert Shift:=xlDown
Range("B2:E2").Select
Selection.Copy
Range("A3").Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=True
Rows("8:11").Select
Application.CutCopyMode = False
Selection.Insert Shift:=xlDown
Range("B7:E7").Select
Selection.Copy
Range("A8").Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=True



End Sub




Please revert.

Thanks in advance.




<tbody>
</tbody>
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
This does as you ask though it seems strange to have the address details twice as per your example

Code:
Sub InsertRowsAndTranspose()

    'Assuming data starts in A2 and spans to E2 and there are no blank rows.
    Dim lNameRow As Long 'row number of next name
    
    lNameRow = 2 'first row of data
    
    Do
        'insert 4 rows
        Rows(lNameRow + 1 & ":" & lNameRow + 4).Insert Shift:=xlDown
        'copy address cells
        Range("B" & lNameRow & ":E" & lNameRow).Copy
        'paste address cells and transpose
        Range("A" & lNameRow + 1).PasteSpecial Paste:=xlPasteAll, Transpose:=True
        'go to next row below
        lNameRow = lNameRow + 5
        'Keep looping until we hit blank row
    Loop Until Len(Range("A" & lNameRow)) = 0
    
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,981
Messages
6,122,565
Members
449,089
Latest member
Motoracer88

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