Copying Data Ranges from One Sheet and Pasting in a Different Order

ph151

New Member
Joined
Jun 5, 2018
Messages
8
Hi All,

Hoping someone can help me sort out a dilemma I am having moving data from one sheet to another.

I have data placed in Sheet List2 in a set order from A2:D2 and subsequent rows (3, 4 and so on).

I am able to copy the first to to Sheet List to where I want it into a new row, however, the remainder content is not being copied over. Please see the code below:

Code:
Sub ExportData()
Dim rng1 As Range, Lst As Long
Dim rng2 As Range, i As Long, cel As Range


    With Sheets("List")
        Set rng2 = .Range("B2,F2,E2,H2")
        Lst = .Range("B" & Rows.Count).End(xlUp).Row
    End With
 
    For Each cel In rng2
        cel(Lst).Value = Sheets("List2").Range(Array("A2", "B2", "C2", "D2")(i))
        i = i + 1
    Next
End Sub

SOURCE DATA (SHEET(LIST2))

ABCD
1RISKIMPACTWBSSTATUS
2RISK 1MILD1.2.2OPEN
3RISK 2SEVERE1.1.2NEW
4RISK 3MILD2.1NEW
5

<tbody>
</tbody>


CURRENT EXPORTED DATA (SHEET(LIST))

ABCDEFGH
1SERRISK........WBSIMPACT....STATUS
2....RISK 1........1.2.2MILD....OPEN
3....RISK 1........1.2.2MILD....OPEN
4....RISK 1........1.2.2MILD....OPEN
5

<tbody>
</tbody>


REQUIRED EXPORTED DATA (SHEET(LIST))

ABCDEFGH
1SERRISK........WBSIMPACT....STATUS
2....RISK 1........1.2.2MILD....OPEN
3....RISK 2........1.1.2SEVERE....NEW
4....RISK 3........2.1MILD....NEW
5

<tbody>
</tbody>


And once the data has been written to the Sheet LIST, any changes to Sheet LIST2 will be written to a new line on Sheet LIST.

I know a big ask, but any help is much appreciated.

Many thanks,

P
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Try this (untested) :
Code:
Sub ExportData()
Dim rng As Range, cel As Range
With Sheets("List2")
    Set rng = .Range(.[A2], .Cells(Rows.Count, "A").End(xlUp))
End With
Set cel = Sheets("List").Cells(Rows.Count, "B").End(xlUp)(2)
With rng
    .Copy cel
    .Offset(0, 1).Copy cel(1, 5)
    .Offset(0, 2).Copy cel(1, 4)
    .Offset(0, 3).Copy cel(1, 7)
End With
End Sub
 
Upvote 0
Hi Footoo,

Many thanks for this. Now tested and works a treat.

Cheers for your help.

Rgds

P
 
Upvote 0

Forum statistics

Threads
1,215,343
Messages
6,124,405
Members
449,157
Latest member
mytux

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