Copy data from Sheet 2 to Sheet1 and paste it in alternate rows in a new sheet

zaveedd

New Member
Joined
Apr 23, 2021
Messages
12
Office Version
  1. 2016
  2. 2010
Platform
  1. Windows
Hi,

I have data in 2 sheets . sheet1 and sheet2 are the sheet names. Data is available A to M in both the sheets.

Both will have same data except 1will have positive value the other will have Negative value.

Both the sheets have row headers .want the output in a new sheet with 2nd row from sheet 1 and 2nd row from sheet 2 ,.3rd row sheet 1 ,3rd row sheet 2 etc. Find below a sample image.

Can anybody help me with the VBA code to get this accomplished?
 

Attachments

  • Query.JPG
    Query.JPG
    119 KB · Views: 7
No I can't reach it but maybe someone else could …​
 
Upvote 0

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
A VBA demonstration as a beginner starter :​
VBA Code:
Sub Demo1()
        If Sheets.Count < 3 Then Sheets.Add , Sheets(2) Else Sheets(3).UsedRange.Clear
        Application.ScreenUpdating = False
    With Sheets(1).UsedRange.Rows
           .Item("1:2").Copy Sheets(3).[A1]
            L& = 2
        For R& = 3 To .Count
            L = L + 2
           .Item(R).Copy Sheets(3).Cells(L, 1)
        Next
    End With
    With Sheets(2).UsedRange.Rows
            L = 1
        For R = 2 To .Count
            L = L + 2
           .Item(R).Copy Sheets(3).Cells(L, 1)
        Next
    End With
        Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,059
Messages
6,122,916
Members
449,093
Latest member
dbomb1414

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