Displaying data from multiple fields based on certain criteria.

Graham C1600

Board Regular
Joined
Feb 17, 2018
Messages
96
Office Version
  1. 365
Hi,
I've been asked to try and source a solution to a problem we are facing. It's a bit complicated so hopefully this will explain my requirements.

I have an excel document with numerous tabs and it's to do with exam passes or fails. The first sheet (let's call it dashboard) looks a little like this :-

TeacherNameGeographyHistoryEnglishScienceMaths
Mrs HStephenFailFailPassPassFail
Mr BRichardPassPassPassPassFail
Mrs CJohnFailFailFailFailFail
Mr WMartinPassPassFailPassPass

So basically this tells me what they have passed and what they have failed.

I then have a further 5 sheets names Geography, History etc... The Geography one look a little like this :-

NameGeographyPass or FailRemediation Actions
FailRevise more


My ask is a follows, I want to be able to click on a specific name (say Stephen) and it then looks across to see what he has failed. Then open a new sheet and populate this new sheet with the tables from Geography, History and Maths sheets as these were the subjects he failed but populate the name with the same name clicked i.e Stephen. So hopefully if I clicked Stephen I would see a new sheet with 3 smaller tables on it showing which subjects he failed and remediation actions. The reason for this is so I can see all the info in one place to pass back to students. Hopefully looking like this.

NameGeographyPass or FailRemediation Actions
StephenGeographyFailRevise more

NameHistoryPass or FailRemediation Actions
StephenHistoryFailStudy Harder

NameMathsPass or FailRemediation Actions
StephenMathsFailRead more Books


Hope this makes sense.

Thanks
 
Try this

Considerations:
1. You manually create the "Output" sheet. The macro will clean the sheet and put the new information each time you double click.
2. Put the code on the sheet where you want the event.
3. You must have created the sheets "Failure 1" to "Failure 6"
4. The columns to validate are: "W", "X", "Y", "Z", "AA", "AD"
5. You must double click on any cell in column "B".

VBA Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
  If Target.Column <> 2 Then Exit Sub
  If Target.Value = "" Or Target.Row < 3 Then Exit Sub

  Dim sh2 As Worksheet, i As Long, arr As Variant
  Set sh2 = Sheets("Output")
  sh2.Cells.Clear
  arr = Array("W", "X", "Y", "Z", "AA", "AD")
  Range("A2:K2, A" & Target.Row & ":K" & Target.Row).Copy sh2.Range("A2")
 
  For i = 0 To UBound(arr)
    If Range(arr(i) & Target.Row) = "Y" Then
      With Sheets("Failure " & i + 1)
        .Range("A1", .Range("F" & Rows.Count).End(3)).Copy sh2.Range("A" & Rows.Count).End(3)(3)
      End With
    End If
  Next
 
  Cancel = True
  sh2.Select
End Sub
Hi Dante, this works a treat. Quick query though.

Is it possible to get the data from the dashboard (Heading 1 - Heading 11) to display on the output along with the data that it is pulling ? So it would look something like this :-

Heading 1Heading 2Heading 3Heading 4Heading 5Heading 6Heading 7Heading 8Heading 9Heading 10Heading 11
345345625C-1505BakersMark DBatch 19117/09/202006/07/202073FAIL1345345625
Check/Column NamePreconditionPriorityAction requiredIssueAction
Heading 23Has itYesTry againNot knownPlan again
Heading 23Had itNoLeave itSimpleLeave


Instead of just displaying the pulled data ?

Thanks for your support.

Graham
 
Upvote 0

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Change this line
VBA Code:
Range("A2:K2, A" & Target.Row & ":K" & Target.Row).Copy sh2.Range("A2")

For this:
VBA Code:
Range("A5:K5, A" & Target.Row & ":K" & Target.Row).Copy sh2.Range("A2")
 
Upvote 0

Forum statistics

Threads
1,214,893
Messages
6,122,121
Members
449,066
Latest member
Andyg666

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