Insert data from one sheet into after every row of another sheet

satis

New Member
Joined
Jul 5, 2021
Messages
4
Office Version
  1. 365
Platform
  1. Windows
Hi,

I'm new to this community, looking for solution for the below requirement. Any help is much appreciated.

want to copy data from one sheet, insert into after every row of another sheet in excel.

Example:

Sheet1:

1.US
2.UK
3.IN
4.CH
5.JP
6.BR

Sheet2:

1. Administrator
2. Customer support
3. Designer
4. Product Engineer
5. Accountant

Sheet2 Output:
1. Administrator

1.US
2.UK
3.IN
4.CH
5.JP
6.BR
2. Customer support
1.US
2.UK
3.IN
4.CH
5.JP
6.BR
3. Designer
1.US
2.UK
3.IN
4.CH
5.JP
6.BR
4. product Engineer
1.US
2.UK
3.IN
4.CH
5.JP
6.BR
5. Accountant
1.US
2.UK
3.IN
4.CH
5.JP
6.BR
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
How about:

VBA Code:
Sub InsertingDataIntoSheet2ColumnA()
'
    Sheets("Sheet2").Range("A2").Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
'
    Sheets("Sheet1").Select
    Range("A1:A6").Copy
    Sheets("Sheet2").Select
    Range("A3").Insert Shift:=xlDown
'
    Sheets("Sheet1").Select
    Range("A1:A6").Copy
    Sheets("Sheet2").Select
    Range("A10").Insert Shift:=xlDown
    
    Sheets("Sheet1").Select
    Range("A1:A6").Copy
    Sheets("Sheet2").Select
    Range("A17").Insert Shift:=xlDown
    
    Sheets("Sheet1").Select
    Range("A1:A6").Copy
    Sheets("Sheet2").Select
    Range("A24").Insert Shift:=xlDown
'
    Sheets("Sheet1").Select
    Range("A1:A6").Copy
    Sheets("Sheet2").Select
    Range("A31").Insert Shift:=xlDown
'
    Application.CutCopyMode = False
End Sub
 
Upvote 0
Hi satis,

maybe try:
VBA Code:
Sub MrE1175625()
'https://www.mrexcel.com/board/threads/insert-data-from-one-sheet-into-after-every-row-of-another-sheet.1175625/
  
  Dim varValues         As Variant
  Dim lngNumberRows     As Long
  Dim lngRow            As Long
    
  varValues = Sheets("Sheet1").Range("A1:A" & Sheets("Sheet1").Range("A" & Rows.Count).End(xlUp).Row).Value2
  lngNumberRows = UBound(varValues)
  With Sheets("Sheet2")
    For lngRow = .Range("A" & .Rows.Count).End(xlUp).Row To 1 Step -1
'      .Cells(lngRow + 1, "A").Resize(lngNumberRows).EntireRow.Insert        'will insert rows
      .Cells(lngRow + 1, "A").Resize(lngNumberRows).Insert                  'will insert cells
      .Cells(lngRow + 1, "A").Resize(lngNumberRows).Value = varValues
    Next lngRow
  End With
  
End Sub
Ciao,
Holger
 
Upvote 0
Shortened version of my previous offering:

VBA Code:
Sub InsertingDataIntoSheet2ColumnA_V2()
'
    Sheets("Sheet2").Range("A2").Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
'
    Sheets("Sheet1").Range("A1:A6").Copy
    Sheets("Sheet2").Range("A3").Insert Shift:=xlDown
'
    Sheets("Sheet1").Range("A1:A6").Copy
    Sheets("Sheet2").Range("A10").Insert Shift:=xlDown
    
    Sheets("Sheet1").Range("A1:A6").Copy
    Sheets("Sheet2").Range("A17").Insert Shift:=xlDown
    
    Sheets("Sheet1").Range("A1:A6").Copy
    Sheets("Sheet2").Range("A24").Insert Shift:=xlDown
'
    Sheets("Sheet1").Range("A1:A6").Copy
    Sheets("Sheet2").Range("A31").Insert Shift:=xlDown
'
    Application.CutCopyMode = False
End Sub
 
Upvote 0
Thanks JohnnyL and Holger. I've tried both solutions, unfortunately this is not working as expected.

 
Upvote 0
Hi satis,

could you please tell us what went wrong with these codes? Both codes try to bring up the result from the opening post Sheet 2 Output example.

Ciao,
Holger
 
Upvote 0
Thanks JohnnyL and Holger. I've tried both solutions, unfortunately this is not working as expected.

The code I posted produces the exact same result you posted for 'Sheet 2 Output:'
 
Upvote 0
Thanks for your efforts. Please find the attachments for output details.
 
Upvote 0
Hi satis,

which attachments?

Ciao,
Holger
 
Upvote 0
Sorry, attachment was missed. Please find the screenshots.
The sheet1 and sheet2 have exact data same as in my question. I've run this macro in sheet2.
 

Attachments

  • Holger solution.png
    Holger solution.png
    31 KB · Views: 7
  • johnny solution.png
    johnny solution.png
    19.2 KB · Views: 8
Upvote 0

Forum statistics

Threads
1,215,584
Messages
6,125,670
Members
449,248
Latest member
wayneho98

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