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
 
Ok here goes Dante,
Dashboard Tab:-
Failure 1Failure 2Failure 3Failure 4Failure 5Failure 6
Heading 1Heading 2Heading 3Heading 4Heading 5Heading 6Heading 7Heading 8Heading 9Heading 10Heading 11Heading 12Heading 13Heading 14Heading 15Heading 16Heading 17Heading 18Heading 19Heading 20Heading 21Heading 22Heading 23Heading 24Heading 25Heading 26Heading 27Heading 28Heading 29Heading 30
1212343C-1500TayloresSimon TBatch 18612/09/202002/07/202072Pass31212343C-1500TayloresGeneric 1Generic 2Generic 3Generic 4Generic 5Generic 6Generic 7YActiveYYYYYGeneric 8Generic 8Y
344422C-1501MusicsBrian WBatch 18713/09/202002/07/202073Pass4344422C-1501MusicsGeneric 1Generic 2Generic 3Generic 4Generic 5Generic 6Generic 7YActiveYYYYYGeneric 9Generic 9Y
3636C-1502BrewerySuzanne RBatch 18814/09/202002/07/202074FAIL23636C-1502BreweryGeneric 1Generic 2Generic 3Generic 4Generic 5Generic 6Generic 7NActiveNNNYYGeneric 10Generic 10Y
3463425253C-1503SampleClare CBatch 18915/09/202002/07/202075FAIL33463425253C-1503SampleGeneric 1Generic 2Generic 3Generic 4Generic 5Generic 6Generic 7NActiveNYNNNGeneric 11Generic 11N
232534636C-1504CloggiesGraham CBatch 19016/09/202002/07/202076FAIL2232534636C-1504CloggiesGeneric 1Generic 2Generic 3Generic 4Generic 5Generic 6Generic 7NActiveNNYYYGeneric 12Generic 12Y
345345625C-1505BakersMark DBatch 19117/09/202002/07/202077FAIL1345345625C-1505BakersGeneric 1Generic 2Generic 3Generic 4Generic 5Generic 6Generic 7NActiveYNNNNGeneric 13Generic 13N
123432C-1506Tom'sSimon TBatch 19218/09/202002/07/202078FAIL32123432C-1506Tom'sGeneric 1Generic 2Generic 3Generic 4Generic 5Generic 6Generic 7NActiveNNNNNGeneric 14Generic 14N


Failure 1 tab:-
Check/Column NamePreconditionPriorityAction requiredIssueAction
Heading 23Has itYesTry againNot knownPlan again
Heading 23Had itNoLeave itSimpleLeave


Failure 2 tab:-
Check/Column NamePreconditionPriorityAction requiredIssueAction
Heading 24HardYesMergeMigratere-code


Output Tab:-
Heading 1Heading 2Heading 3Heading 4Heading 5Heading 6Heading 7Heading 8Heading 9Heading 10Heading 11
3636C-1502BrewerySuzanne RBatch 18814/09/202002/07/202074Pass23636
Check/Column NamePreconditionPriorityAction requiredIssueAction
Heading 23Has itYesTry againNot knownPlan again
Heading 23Had itNoLeave itSimpleLeave
Check/Column NamePreconditionPriorityAction requiredIssueAction
Heading 24HardYesMergeMigratere-code


So let me explain,
Looking down Column I to find a fail.
All the fails are listed in Columns W,X,Y,Z,AA & AD. If it shows an "N" it has failed.
Double click the name in Column C8 (this is the first that has failed). We can see across to column AD it failed on 3 counts (W8,X8 & Y8). So the ask here is to look across the row for the N's in columns W,X,Y,Z,AA & AD.
Now on the output tab I want to display like I have in the sample. Note that I have only used 2 x failures but realistically there could be 6. There will be a further 4 tabs created to show failures 3,4,5 & 6.

Hope this makes sense. It worked really well on the small dummy one you did so hopefully you can replicate onto this spreadsheet.

I also have another spreadsheet with pretty much the same layout but a few more failures. Are you able to explain how I can adapt your code to include some more looking for the N's and displaying more failures ?

Thanks for your time Dante.

Graham
 
Upvote 0

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Right now I have more questions than solutions.
1. The macro should create the sheets: Failure 1 tab and Failure 2 tab?
2. Why did you put Heading 23 twice in the output tab?
3. In the Ouput tab you put these data: "Precondition, Priority, Action required, Issue, Action". Where do I get this data from?
4. In your example for "Brewery" did you omit "Heading 25"?
 
Upvote 0
Dante,
Answers below:-
1. The macro should create the sheets: Failure 1 tab and Failure 2 tab?
The macros needs to look across the worksheet and where there is a "N" in columns W,X,Y,Z,AA & AD and then pull data from the relevant other tabs i.e Failure 1 etc.. I only added 2 x Failure tabs but there will be 6 on the finished spreadsheet.
2. Why did you put Heading 23 twice in the output tab?
This is because for this failure there are 2 x possible solutions. So on the Dashboard tab is shows as a failure "Heading 23" but there are a couple of solutions to fix it. It's a bit of duplication but i'd rather have it if i could.
3. In the Ouput tab you put these data: "Precondition, Priority, Action required, Issue, Action". Where do I get this data from?
The output tab is what i want the actual output to look like when you double click the name in Column C. So this wouldn't be there in the start of the spreadsheet. The output has taken data from the dashboard tab and also the Failure Tabs (depending if they failed of not.
4. In your example for "Brewery" did you omit "Heading 25"?
Yes i did, there would be another 4 tabs in the finished spreadsheet showing failures 3,4,5,& 6. Do you want me to add the other tabs and upload them ? they will be pretty much the same as failures 1 & 2 in structure but the text will be slightly different.

Thanks
 
Upvote 0
I'm sorry but I don't understand your answers.

I will try again.

1. The macro should create the sheets: Failure 1 tab and Failure 2 tab? Yes or No.

2. Why did you put Heading 23 twice in the output tab? How to know if it is one or two?

3. In the Ouput tab you put these data: "Precondition, Priority, Action required, Issue, Action". Where do I get this data from?
1593805929356.png

How to put those data? you can explain in detail, at least explain 2 of those data.

4. In your example for "Brewery" did you omit "Heading 25"? Yes or No.
 
Upvote 0
I'm sorry but I don't understand your answers.

I will try again.

1. The macro should create the sheets: Failure 1 tab and Failure 2 tab? Yes or No.
In the example i sent it is yes. However on my actual spreadsheet there are 6 failure tabs. I will load a new form with all 6 failures on.

2. Why did you put Heading 23 twice in the output tab? How to know if it is one or two?
This can be seen from looking at the failure tabs. Sometimes there might be 2 issues to report on and sometimes only one.


3. In the Ouput tab you put these data: "Precondition, Priority, Action required, Issue, Action". Where do I get this data from?
View attachment 17562
How to put those data? you can explain in detail, at least explain 2 of those data.

This data is found on the failure tabs.

4. In your example for "Brewery" did you omit "Heading 25"? Yes or No.
I will upload the full forms so you can see everything.

So the output tab is taking details from the dashboard tab (Headings 1 to 11)
Then takes details from the relevant failure tabs (W,X,Y,Z,AA & AD)
This is all based on double clicking the name in Column C.

Below are updated forms.
Failure 1Failure 2Failure 3Failure 4Failure 5Failure 6
Heading 1Heading 2Heading 3Heading 4Heading 5Heading 6Heading 7Heading 8Heading 9Heading 10Heading 11Heading 12Heading 13Heading 14Heading 15Heading 16Heading 17Heading 18Heading 19Heading 20Heading 21Heading 22Heading 23Heading 24Heading 25Heading 26Heading 27Heading 28Heading 29Heading 30
1212343C-1500TayloresSimon TBatch 18612/09/202006/07/202068Pass31212343C-1500TayloresGeneric 1Generic 2Generic 3Generic 4Generic 5Generic 6Generic 7YActiveYYYYYGeneric 8Generic 8Y
344422C-1501MusicsBrian WBatch 18713/09/202006/07/202069Pass4344422C-1501MusicsGeneric 1Generic 2Generic 3Generic 4Generic 5Generic 6Generic 7YActiveYYYYYGeneric 9Generic 9Y
3636C-1502BrewerySuzanne RBatch 18814/09/202006/07/202070FAIL23636C-1502BreweryGeneric 1Generic 2Generic 3Generic 4Generic 5Generic 6Generic 7NActiveNNNYYGeneric 10Generic 10Y
3463425253C-1503SampleClare CBatch 18915/09/202006/07/202071FAIL33463425253C-1503SampleGeneric 1Generic 2Generic 3Generic 4Generic 5Generic 6Generic 7NActiveNYNNNGeneric 11Generic 11N
232534636C-1504CloggiesGraham CBatch 19016/09/202006/07/202072FAIL2232534636C-1504CloggiesGeneric 1Generic 2Generic 3Generic 4Generic 5Generic 6Generic 7NActiveNNYYYGeneric 12Generic 12Y
345345625C-1505BakersMark DBatch 19117/09/202006/07/202073FAIL1345345625C-1505BakersGeneric 1Generic 2Generic 3Generic 4Generic 5Generic 6Generic 7NActiveYNNNNGeneric 13Generic 13N
123432C-1506Tom'sSimon TBatch 19218/09/202006/07/202074FAIL32123432C-1506Tom'sGeneric 1Generic 2Generic 3Generic 4Generic 5Generic 6Generic 7NActiveNNNNNGeneric 14Generic 14N


Failure 1
Check/Column NamePreconditionPriorityAction requiredIssueAction
Heading 23Has itYesTry againNot knownPlan again
Heading 23Had itNoLeave itSimpleLeave


Failure 2
Check/Column NamePreconditionPriorityAction requiredIssueAction
Heading 24HardYesMergeMigratere-code


Failure 3
Check/Column NamePreconditionPriorityAction requiredIssueAction
Heading 25Has itYesNo ActionKnownRepeat


Failure 4
Check/Column NamePreconditionPriorityAction requiredIssueAction
Heading 26Do itYesLeave againNot knownPlan again
Heading 26Do itNoRepeat nowSimpleLeave


Failure 5
Check/Column NamePreconditionPriorityAction requiredIssueAction
Heading 27KnownNotReturnBlankPlan again


Failure 6
Check/Column NamePreconditionPriorityAction requiredIssueAction
Heading 30MightyYesAbandonNot knownPlan again
Heading 30SmallNoSubmitSimpleLeave


Output Tab
Heading 1Heading 2Heading 3Heading 4Heading 5Heading 6Heading 7Heading 8Heading 9Heading 10Heading 11
3636C-1502BrewerySuzanne RBatch 18814/09/202006/07/202070Pass23636
Check/Column NamePreconditionPriorityAction requiredIssueAction
Heading 23Has itYesTry againNot knownPlan again
Heading 23Had itNoLeave itSimpleLeave
Check/Column NamePreconditionPriorityAction requiredIssueAction
Heading 24HardYesMergeMigratere-code
Check/Column NamePreconditionPriorityAction requiredIssueAction
Heading 25Has itYesNo ActionKnownRepeat


Thanks
 
Upvote 0
Perhaps there are many doubts.
We are going to solve only the first one and we are moving forward.

1. The macro should create the sheets: Failure 1 tab and Failure 2 tab? Yes or No.
In the example i sent it is yes. However on my actual spreadsheet there are 6 failure tabs. I will load a new form with all 6 failures on.

So every time you run the macro, the macro should create 6 sheets?
 
Upvote 0
Perhaps there are many doubts.
We are going to solve only the first one and we are moving forward.

1. The macro should create the sheets: Failure 1 tab and Failure 2 tab? Yes or No.
In the example i sent it is yes. However on my actual spreadsheet there are 6 failure tabs. I will load a new form with all 6 failures on.

So every time you run the macro, the macro should create 6 sheets?
Dante,

So the standard form will have the dashboard populated with data. The tabs Failure 1-6 will be there with standard data on them so they do not need creating.
So when you double click a name down column C, I want a look across the row to columns W,X,Y,Z,AA & AD to see if there is an N there. The failure tabs reflect these columns so if there is an N in column W (this is failure 1).

The ask here on double click is as follows :-
  1. Create a new sheet
  2. Firstly on the new sheet, show headings 1 - 11 as per the name clicked in column C.
  3. Then depending if there are N's in W,X,Y,Z,AA & AD, also add to the new sheet the small tables from the related failures.
Thanks and apologies for any confusion.
 
Upvote 0
Sorry, but it's still very confusing to me.
I just want you to answer a simple question:

1. The macro should create the sheets: Failure 1 tab and Failure 2 tab? Yes or No.

"In the example i sent it is yes. "
" The tabs Failure 1-6 will be there with standard data on them so they do not need creating. "

Please answer Yes or No.
Your answers are ambiguous, sometimes yes, sometimes no.

After I understand the first of my doubts, we move on to the next question. While I can't move forward.
 
Upvote 0
Sorry, but it's still very confusing to me.
I just want you to answer a simple question:

1. The macro should create the sheets: Failure 1 tab and Failure 2 tab? Yes or No.

"In the example i sent it is yes. "
" The tabs Failure 1-6 will be there with standard data on them so they do not need creating. "

Please answer Yes or No.
Your answers are ambiguous, sometimes yes, sometimes no.

After I understand the first of my doubts, we move on to the next question. While I can't move forward.
The macro will not create failure sheets, only the output sheet. The failure sheets are already there in the spreadsheet.
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,215,064
Messages
6,122,936
Members
449,094
Latest member
teemeren

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