vba for copy and paste data to above row

Vishaal

Well-known Member
Joined
Mar 16, 2019
Messages
543
Office Version
  1. 2010
  2. 2007
Platform
  1. Windows
  2. Web
We have the following data, and want to copy and paste as per result sheet,

Data
ACTIVE SUBSCRIBER.XLSX
ABCDE
2070986SHUTBJTNEFT10/30/21987453.00
21FDSFJDSFLDSJFSDKLSDHFDSHFHASDFDSFDSFSDF1-Dec-211-Nov-22
22TELDFDSFS
23980874AHDFDFPUM11/1/2198765.00
24DFSFD FDSFSDF 4335353535351-Dec-211-Nov-22
25Email: raghib1993@gmail.comOB: 8209043164PUM
Sheet1



result data
ACTIVE SUBSCRIBER.XLSX
ABCDEFGHIJK
2070986SHUTBJTNEFT10/30/21987453.00FDSFJDSFLDSJFSDKLSDHFDSHFHASDFDSFDSFSDF1-Dec-211-Nov-22TELDFDSFS
21
22
23980874AHDFDFPUM11/1/2198765.00DFSFD FDSFSDF 4335353535351-Dec-211-Nov-22Email: raghib1993@gmail.comOB: 8209043164PUM
Sheet1
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Hi maybe this code can help you , assuming data is in col A as you have it, and starts row 1 (else adjust the count 1 to LR to 2 to LR, or 3 to LR etc..)

VBA Code:
Sub move_data()

Dim LR, RC As Long

LR = ActiveSheet.Cells(Rows.Count, 2).End(xlUp).Row  ' check col 2 for last row of data

For RC = 1 To LR

    If ActiveSheet.Cells(RC, 1) <> "" Then 'check if column A has a value (ie. is the first line in the set of 3)
    
        ActiveSheet.Range(Cells(RC + 1, 2), Cells(RC + 1, 4)).Cut (ActiveSheet.Range(Cells(RC, 6), Cells(RC, 8)))
        ActiveSheet.Range(Cells(RC + 2, 2), Cells(RC + 2, 4)).Cut (ActiveSheet.Range(Cells(RC, 9), Cells(RC, 11)))
        
    End If

Next RC

End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,224,812
Messages
6,181,089
Members
453,021
Latest member
Justyna P

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