Return Multiple Result Two Dimensions

zaki1979

New Member
Joined
Jun 7, 2022
Messages
20
Office Version
  1. 2019
Platform
  1. Windows
Dear Expert,

I am working in a small project. I have attached my simple data (Input & output)

Master Data Sheet looks like as follows:

Employee ID Client Name Site Name 01/02 02/02 03/02 04/02 05/02 06/02 07/02 08/02
201101 Client A Site X P P A
201101 Client B Site Y P P P
201101 Client C Site Z P A and till the end of the Month of February 2022 (Where P represents Present & A represents Absent)

I have another Sheets (Output Sheet)/Report which will display only unique employee Id I want the result to be displayed as follows:

Employee ID 01/02 02/02 03/02 04/02 05/02 06/02 07/02 08/02 .................................28/02
201101 P P A P P P P A.
201102
201103
etc...

I know that I have to use Index/Match but unfortunately I couldn't solve the task. Is there a way to use Index/Match with Offset
any solution will be highly appreciated.

Many thanks in advance for your precious time and consideration. Looking forward to hear from you as soon as possible.





Kindly note that I am using office 2019.
 

Attachments

  • MASTER DATA SHEET.png
    MASTER DATA SHEET.png
    248.4 KB · Views: 13

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Hi and welcome to MrExcel!

It would help greatly if you could give us the sample data in a form that we can copy to test with, rather that a picture.
MrExcel has a tool called “XL2BB” that lets you post samples of your data that will allow us to copy/paste it to our Excel spreadsheets, so we can work with the same copy of data that you are.

Instructions on using this tool can be found here: XL2BB Add-in

Note that there is also a "Test Here” forum on this board. This is a place where you can test using this tool (or any other posting techniques that you want to test) before trying to use those tools in your actual posts.
 
Upvote 0
Dear Expert,

Many thanks for your reply. Kindly note that here below is my Master Data Sheet (Input Data):
New Microsoft Excel Worksheet.xlsx
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAGAHAIAJ
1
2PPRESENT
3AABSENCE
4MMALADE
5RREPOT
6
7MATRICULENOMÉQUIPEFONCTIONCLIENTSITEREMARQUESUNIQUE_ID01020304050607080910111213141516171819202122232425262728
8201101MIDO MIWUMBUAGUARDECLIENT 1SITE ARAS201101_8PPPPPPPPPPPPPPPPPP
9201102AKANGA ALONDOAGUARDECLIENT 2SITE BRAS201102_9PPPPPPPPPPPPPPPPPPPPPPMMMMPP
10201103INGANGE EYENGABGUARDECLIENT 3SITE CRAS201103_10PPPPPPPAAPPPPPPPPPPPPPPPPPPP
11201101MIDO MIWUMBUAGUARDECLIENT 4SITE DTRANSFERT #101201101_11PPPAAPPPRP
MASTER DATA
Cell Formulas
RangeFormula
H8:H11H8=A8&"_"&ROW()
Cells with Conditional Formatting
CellConditionCell FormatStop If True
I8:AJ12Cell Value="R"textNO
I8:AJ12Cell Value="M"textNO
I8:AJ12Cell Value="A"textNO
I8:AJ12Cell Value="P"textNO


I have another Sheets (Output Sheet)/Report which will display only unique employee Id I want the result to be displayed as follows:
New Microsoft Excel Worksheet.xlsx
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAF
3MATRICULEFONCTION01020304050607080910111213141516171819202122232425262728TOTAL PRESENCETOTAL ABSENCE
4201101GUARDEPPPPPPPPPPPPPPPPPPPPPAAPPPRP252
5201102GUARDEPPPPPPPPPPPPPPPPPPPPPPMMMMPP240
6201103GUARDEPPPPPPPAAPPPPPPPPPPPPPPPPPPP262
ATTENDANCE REPORT
Cell Formulas
RangeFormula
AE4:AE6AE4=COUNTIF(C4:AD4,"P")
AF4:AF6AF4=COUNTIF(C4:AD4,"A")


I know that I have to use Index/Match but unfortunately I couldn't solve the task. Is there a way to use Index/Match with Offset
any solution will be highly appreciated.

Many thanks in advance for your precious time and consideration. Looking forward to hear from you as soon as possible.
 
Upvote 0
In the sheet "Master data" you have 2 times the MATRICULE "201101", it may be that on the same day it has 2 letters, or always only one letter will exist?
If there are 2 letters which of them should I put?
 
Upvote 0
Yes sir, of course it must be like that because it means employee 201101 worked from 01/02 till 18/02 in site A
then he worked from 19/02 till 28/02 in Site D.

In the Master Sheet the Attendance has been registered based on their Location, but when I want to create my report I
wanted to be displayed without caring about their locations. It's about continuous attendance.

I tried to solve my problem using VBA as follows and it works fine till now. I will prefer to do it using a Formula
hope you will resolve my task.

Here's VBA code tell me what you think about it:

Sub GetAttendance()

On Error Resume Next

Dim mSheet As Worksheet: Set mSheet = ThisWorkbook.Sheets("ATTENDANCE")
Dim cSheet As Worksheet: Set cSheet = ThisWorkbook.Sheets("RP03")
Dim m_lRow As Long: m_lRow = mSheet.Range("A" & Rows.Count).End(xlUp).Row
Dim c_lRow As Long: c_lRow = cSheet.Range("A" & Rows.Count).End(xlUp).Row
Dim c, rng As Range
Dim i, j, k As Long

j = 2
k = 6

Do While j <= c_lRow
'loop through Master Sheet....
For Each c In mSheet.Range("A12:AR" & m_lRow)
'Assign values from Report Sheet to check within Master sheet....
If c.Value = cSheet.Range("A" & j).Value Then
'If exists then read values from column N till the last column
For i = 13 To 43
'If cell is empty don't execute...
If c.Offset(0, i).Value <> "" Then
'loop through columns in Sheet Report/Output
For k = 6 To 36
If (i - k) = 7 Then
'Write back the result into Report sheet in their place....
cSheet.Cells(j, k).Value = c.Offset(0, i).Value
Exit For
End If
Next k
End If
Next i
End If
Next c
'increment the index to move 1 row in the report sheet
j = j + 1
Loop

End Sub
 
Upvote 0
I will prefer to do it using a Formula
Try this:

Dante Amor
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAF
1
2
3MATRICULEFONCTION01020304050607080910111213141516171819202122232425262728TOTAL PRESENCETOTAL ABSENCE
4201101GUARDEPPPPPPPPPPPPPPPPPPPPPAAPPPRP252
5201102GUARDEPPPPPPPPPPPPPPPPPPPPPPMMMMPP240
6201103GUARDEPPPPPPPAAPPPPPPPPPPPPPPPPPPP262
Atrtendance report
Cell Formulas
RangeFormula
C4:AD6C4=INDEX('Master data'!$A$1:$AJ$11,MAX(IF('Master data'!$A$8:$A$11=$A4,IF('Master data'!$I$8:$AJ$11<>"",IF('Master data'!$I$7:$AJ$7=C$3,ROW('Master data'!$A$8:$A$11))))),MATCH(C$3,'Master data'!$A$7:$AJ$7,0))
AE4:AE6AE4=COUNTIF(C4:AD4,"P")
AF4:AF6AF4=COUNTIF(C4:AD4,"A")
Press CTRL+SHIFT+ENTER to enter array formulas.



Note:
In future please use code tags when posting code. How to Post Your VBA Code it makes your code easier to read andcopy and it also maintains VBA formatting.
 
Upvote 0
Dear Sir, I don't what code tag means. Actually it's my 1st time I use a sit like that. please explain to me what do you mean by Code Tags.
I will try the your formula then I'll refer back to you. Really thanks a lot for all the efforts you did.
 
Upvote 0
Dear Sir,

I really can't thank you enough because you make my life easier. You are amazing
May GOD bless you since you are helping people.
 
Upvote 0
Dear Sir, I don't what code tag means. Actually it's my 1st time I use a sit like that. please explain to me what do you mean by Code Tags.
I will try the your formula then I'll refer back to you. Really thanks a lot for all the efforts you did.

I mean you put this code without using code tags.
Sub GetAttendance()
On Error Resume Next
Dim mSheet As Worksheet: Set mSheet = ThisWorkbook.Sheets("ATTENDANCE")
Dim cSheet As Worksheet: Set cSheet = ThisWorkbook.Sheets("RP03")
'...etc
End Sub

When you use code tags it looks like this:
VBA Code:
Sub GetAttendance()
On Error Resume Next
Dim mSheet As Worksheet: Set mSheet = ThisWorkbook.Sheets("ATTENDANCE")
Dim cSheet As Worksheet: Set cSheet = ThisWorkbook.Sheets("RP03")
'...etc
End Sub

To put the code tags click on the VBA-code icon, you find it in the icon bar:
1654772812576.png



After pressing the icon, in the panel the code tags appear, between the tags you must put your code.
1654772987376.png
 
Upvote 0
Dear Sir,

I really can't thank you enough because you make my life easier. You are amazing
May GOD bless you since you are helping people.
I'm glad to help you. Thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,215,487
Messages
6,125,086
Members
449,206
Latest member
ralemanygarcia

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