Copying Data from one sheet to another based on certain cell data

mphetherington

New Member
Joined
May 23, 2019
Messages
1
Hi everyone,

I have a query about copying data from one sheet to another based on a range of data in a certain column.

I have created an assessment grades workbook which contains a number of sheets. Each sheet represents a module on the course, and also contains a stats sheet and a cohort sheet. From the cohort sheet I am able to populate the students onto the modules HEL3000 - HEL3003. These are core modules which all student must attend and pass. I do have however specialist modules which only certain students must attend. For Example HEL3004 should only include students who belong to education courses. On the cohort sheet these student would be denoted by the course abbr's PQTS, EDS, ECS, WW and SW. My question is how would I make sure only those students with the education abbrs listed above only get copied across to HEL3004?

I'm currently using the following formula:
=IF(Cohort!A14=0," ",Cohort!A14) to copy data from a specific cell to a cell on the destination sheet. However, I think I would need to include something like and IF/OR statement to complete this. Would this be correct?

The below info would be on sheet called 'Cohort'

Column/Row
A
B
C
D
E
13
Student Number
Surname
First Name
Route Code
Course
14
1
Smith
Bob
AAC
PQTS
15
2
Greene
Jane
DDS
AN
16
3
Brown
Jack
AAB
ECS

<tbody>
</tbody>

The sheet called 'HEL3004' would take the first four cells from sheet cohort only if the course included (PQTS, EDS, ECS, WW, or SW)

Column/Row
A
B
C
D
13
Student Number
Surname
First Name
Route Code
14
1
Smith
Bob
AAC
15
3
Brown
Jack
AAB

<tbody>
</tbody>


Apologies, this is my first time using a forum to ask for support. I've usually been successful with just completing a good search. Any guidance would be greatly appreciated.

many thanks

Mark
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Hi Mark,

Welcome to the forum!

Try this macro on a copy of your workbook:

Sub copy_edu()
Dim lastrow As Integer, x As Integer, course As String
lastrow = Sheets("Cohort").Cells(Rows.Count, 1).End(xlUp).Row

For x = 2 To lastrow
course = Cells(x, 5).Value
Select Case course
Case Is = "PQTS"
Rows(x).Copy
Sheets("HEL3004").Range("A" & Rows.Count).End(xlUp).Offset(1).PasteSpecial

Case Is = "EDS"
Rows(x).Copy
Sheets("HEL3004").Range("A" & Rows.Count).End(xlUp).Offset(1).PasteSpecial

Case Is = "ECS"
Rows(x).Copy
Sheets("HEL3004").Range("A" & Rows.Count).End(xlUp).Offset(1).PasteSpecial

Case Is = "WW"
Rows(x).Copy
Sheets("HEL3004").Range("A" & Rows.Count).End(xlUp).Offset(1).PasteSpecial

Case Is = "SW"
Rows(x).Copy
Sheets("HEL3004").Range("A" & Rows.Count).End(xlUp).Offset(1).PasteSpecial
Case Else

End Select

Next x

End Sub

Assuming there are no empty rows between data, this will copy the correct rows from "Cohort" and paste them one after the other into "HEL3004"


All the best,
Matt
 
Upvote 0

Forum statistics

Threads
1,214,792
Messages
6,121,612
Members
449,038
Latest member
apwr

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