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'

[TABLE="class: grid, width: 600, align: center"]
<tbody>[TR]
[TD="align: center"]Column/Row
[/TD]
[TD="align: center"]A
[/TD]
[TD="align: center"]B
[/TD]
[TD="align: center"]C
[/TD]
[TD="align: center"]D
[/TD]
[TD="align: center"]E
[/TD]
[/TR]
[TR]
[TD="align: right"]13
[/TD]
[TD="align: center"]Student Number
[/TD]
[TD="align: center"]Surname
[/TD]
[TD="align: center"]First Name
[/TD]
[TD="align: center"]Route Code
[/TD]
[TD="align: center"]Course
[/TD]
[/TR]
[TR]
[TD="align: right"]14
[/TD]
[TD="align: center"]1
[/TD]
[TD="align: center"]Smith
[/TD]
[TD="align: center"]Bob
[/TD]
[TD="align: center"]AAC
[/TD]
[TD="align: center"]PQTS
[/TD]
[/TR]
[TR]
[TD="align: right"]15
[/TD]
[TD="align: center"]2
[/TD]
[TD="align: center"]Greene
[/TD]
[TD="align: center"]Jane
[/TD]
[TD="align: center"]DDS
[/TD]
[TD="align: center"]AN
[/TD]
[/TR]
[TR]
[TD="align: right"]16
[/TD]
[TD="align: center"]3
[/TD]
[TD="align: center"]Brown
[/TD]
[TD="align: center"]Jack
[/TD]
[TD="align: center"]AAB
[/TD]
[TD="align: center"]ECS
[/TD]
[/TR]
</tbody>[/TABLE]

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

[TABLE="class: grid, width: 600, align: center"]
<tbody>[TR]
[TD]Column/Row
[/TD]
[TD="align: center"]A
[/TD]
[TD="align: center"]B
[/TD]
[TD="align: center"]C
[/TD]
[TD="align: center"]D
[/TD]
[/TR]
[TR]
[TD="align: right"]13
[/TD]
[TD="align: center"]Student Number
[/TD]
[TD="align: center"]Surname
[/TD]
[TD="align: center"]First Name
[/TD]
[TD="align: center"]Route Code
[/TD]
[/TR]
[TR]
[TD="align: right"]14
[/TD]
[TD="align: center"]1
[/TD]
[TD="align: center"]Smith
[/TD]
[TD="align: center"]Bob
[/TD]
[TD="align: center"]AAC
[/TD]
[/TR]
[TR]
[TD="align: right"]15
[/TD]
[TD="align: center"]3
[/TD]
[TD="align: center"]Brown
[/TD]
[TD="align: center"]Jack
[/TD]
[TD="align: center"]AAB
[/TD]
[/TR]
</tbody>[/TABLE]


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

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
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,223,893
Messages
6,175,239
Members
452,621
Latest member
Laura_PinksBTHFT

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