VBA - Copy certain columns, but need to replace data on the ultimate sheet

NathanA

New Member
Joined
Jan 18, 2017
Messages
34
I am using code to copy over certain columns if two conditions are met, however, I would like for the code to replace what is already on 'Emerging' (the ultimate sheet). Any guidance would be much appreciated.

Code:
Sub Emerging()


Set i = Sheets("Under achievement data")
Set e = Sheets("Emerging")
Dim d
Dim j
d = 1
j = 2


'Choose length of data to copy
Do Until IsEmpty(i.Range("A" & j))
    'Specify criteria
    If i.Range("J" & j) <> "" And _
    i.Range("G" & j) = "Emerging" Then
    d = d + 1
    'Select columns to copy
'            e.Rows(d).Value = i.Rows(j).Value
'            1, 3, 6, 7, 8, 9, and 10
            e.Cells(d, 3).Value = i.Cells(j, 1).Value
            e.Cells(d, 6).Value = i.Cells(j, 3).Value
            e.Cells(d, 1).Value = i.Cells(j, 6).Value
            e.Cells(d, 2).Value = i.Cells(j, 7).Value
            e.Cells(d, 7).Value = i.Cells(j, 8).Value
            e.Cells(d, 5).Value = i.Cells(j, 9).Value
            e.Cells(d, 4).Value = i.Cells(j, 10).Value


End If
j = j + 1
Loop


End Sub
[\code]
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.

Forum statistics

Threads
1,224,823
Messages
6,181,185
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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