Hi Rashid,

Sorry i can't upload file so please follow the given steps:

*Step 1:-   First create a sample sheet for output report with all the 
formatting and formula and please make sure it should be for 31 rows as    *
*max day in a month is 31.*
*Step 2:-   Press Alt + F11 and Alt + I + M and paste below code *
*
*
*Option Explicit

Sub GetEmployeeAttendance()

    Dim wksSht                          As Worksheet
    Dim wksReport                       As Worksheet
    Dim rngRange                        As Range
    Dim varData()                       As Variant
    Dim varName()                       As Variant
    Dim varDate()                       As Variant
    Dim varFinal()                      As Variant
    Dim lngLoopName                     As Long
    Dim lngLoopDate                     As Long
    Dim lngCount                        As Long
    Const strFormula                    As String = "=A1 & ""|"" & 
TEXT(B1,""m/d/yyyy"")"
    Const strTmpSht                     As String = "Temp_Sht"
    Const strDataStartCell              As String = "A1"
    Const strFinalDataStartCell         As String = "D8"
    Const strReportMonthCell            As String = "C2"
    Const strEmpNameCell                As String = "C5"
    Const strSampleFileName             As String = "Sample"
    
    ReDim varData(0)
    
    With ThisWorkbook.Worksheets("Master")
        Set rngRange = .Range(strDataStartCell).Resize(.Cells(.Rows.Count, 
1).End(xlUp).Row, 2)
        varData = rngRange.Value
    End With
    
    If UBound(varData) > 0 Then
        
        Application.DisplayAlerts = False
        
        On Error Resume Next
        Worksheets(strTmpSht).Delete
        On Error GoTo 0: Err.Clear
        
        Set wksSht = Worksheets.Add
        With wksSht
            .Name = strTmpSht
            With .Range(strDataStartCell)
                .Resize(UBound(varData), UBound(varData, 2)).Value = varData
                .Resize(UBound(varData), 1).RemoveDuplicates Columns:=1, 
Header:=xlYes
            End With
            varName = Intersect(.Range(strDataStartCell, 
.Cells(.Rows.Count, 1).End(xlUp)), .Range(strDataStartCell, 
.Cells(.Rows.Count, 1).End(xlUp)).Offset(1)).Value
            varName = Application.Transpose(varName)
            With .Range(strDataStartCell)
                .Resize(UBound(varData), UBound(varData, 2)).Value = varData
                .Resize(UBound(varData), 1).Offset(, UBound(varData, 
2)).Formula = strFormula
                .Resize(UBound(varData), 1).Offset(, UBound(varData, 
2)).Value = .Resize(UBound(varData), 1).Offset(, UBound(varData, 2)).Value
                .Resize(UBound(varData), 1).Offset(, UBound(varData, 
2)).RemoveDuplicates Columns:=1, Header:=xlYes
            End With
            varDate = .Range(.Range(strDataStartCell).Offset(1, 
UBound(varData, 2)), .Cells(.Rows.Count, UBound(varData, 2) + 
1).End(xlUp)).Value
            varDate = Application.Transpose(varDate)
            .Cells.Clear
            With .Range(strDataStartCell)
                .Resize(UBound(varData), UBound(varData, 2)).Value = varData
            End With
        End With
        
        With wksSht
            Set rngRange = .Range(strDataStartCell).CurrentRegion
            rngRange.Resize(1, 1).Offset(, 7).Formula = 
"=IFERROR(TEXT(SUBTotal(105," & rngRange.Resize(, 1).Offset(, 1).Address(, 
, , 1) & "),""yyyy""), """")" 'Year
            rngRange.Resize(1, 1).Offset(, 8).Formula = 
"=IFERROR(TEXT(SUBTotal(105," & rngRange.Resize(, 1).Offset(, 1).Address(, 
, , 1) & "),""mmmm""), """")" 'Month
            rngRange.Resize(1, 1).Offset(, 9).Formula = 
"=IFERROR(INT(SUBTotal(105," & rngRange.Resize(, 1).Offset(, 1).Address(, , 
, 1) & ")), """")" 'Date
            rngRange.Resize(1, 1).Offset(, 10).Formula = 
"=IFERROR(SUBTotal(105," & rngRange.Resize(, 1).Offset(, 1).Address(, , , 
1) & "), """")" 'Min
            rngRange.Resize(1, 1).Offset(, 11).Formula = 
"=IFERROR(SUBTotal(104," & rngRange.Resize(, 1).Offset(, 1).Address(, , , 
1) & "), """")" 'Max
            With rngRange.Resize(1, 2)
                .AutoFilter
                For lngLoopName = LBound(varName) To UBound(varName)
                    ReDim varFinal(1 To 31, 1 To 3)
                    lngCount = 0
                    rngRange.AutoFilter Field:=1, 
Criteria1:=varName(lngLoopName)
                    For lngLoopDate = LBound(varDate) To UBound(varDate)
                        If varDate(lngLoopDate) Like varName(lngLoopName) & 
"|*" Then
                            rngRange.AutoFilter Field:=2, 
Operator:=xlFilterValues, Criteria2:=Array(2, Split(varDate(lngLoopDate), 
"|")(1))
                            If rngRange.Resize(1, 1).Offset(, 9).Value <> 0 
Then
                                lngCount = lngCount + 1
                                varFinal(lngCount, 1) = rngRange.Resize(1, 
1).Offset(, 9).Value
                                varFinal(lngCount, 2) = rngRange.Resize(1, 
1).Offset(, 10).Value
                                varFinal(lngCount, 3) = rngRange.Resize(1, 
1).Offset(, 11).Value
                            End If
                        End If
                    Next lngLoopDate
                    If varFinal(1, 1) <> "" Then
                        On Error Resume Next
                        Worksheets(varName(lngLoopName)).Delete
                        On Error GoTo 0: Err.Clear
                        Worksheets(strSampleFileName).Visible = True
                        Worksheets(strSampleFileName).Copy 
After:=Sheets(Worksheets.Count)
                        Worksheets(strSampleFileName).Visible = xlVeryHidden
                        Set wksReport = Sheets(Worksheets.Count)
                        With wksReport
                            .Name = varName(lngLoopName)
                            .Range(strReportMonthCell).Value = 
Format(varFinal(1, 1), "mmmm") & " Attendance Report " & Format(varFinal(1, 
1), "yyyy")
                            .Range(strEmpNameCell).Value = "Employee Name: 
" & .Name
                            
.Range(strFinalDataStartCell).Resize(UBound(varFinal), 
UBound(varFinal, 2)).Value = varFinal
                            .Cells.EntireColumn.AutoFit
                        End With
                    End If
                Next lngLoopName
            End With
        End With
        
        On Error Resume Next
        Worksheets(strTmpSht).Delete
        On Error GoTo 0: Err.Clear
        
        Application.DisplayAlerts = True
    End If

End Sub*
*
*
*Step 3:-   Create a shape in master sheet and assign this macro to the 
shape.*
*Step 4:-   Make sure the input time format should be always in m/d/yyyy 
format if in future it change then need to change code also.*

Let me know if you need my further assistance.

Regards,
Lalit Mohan

On Monday, 31 December 2012 13:05:42 UTC+5:30, prkhan56 wrote:
>
> Hello Lalit
> Please see the Master Sheet Col A and Col B
> Also I am pasting one of the previous post here
>
> *Where is the out time of the employees.*
> Please see this sample data of employee A for 1st Nov only.  Data for the 
> same employee is also there in my previous sample sheet in Col B against 
> his name.
>
> Name A                11/1/2012 8:13 ----*IN TIME*
>
> Name A                11/1/2012 8:13
>
> Name A                11/1/2012 19:52
>
> Name A                11/1/2012 19:52
>
> Name A                11/1/2012 19:52
>
> Name A                11/1/2012 19:52 ----*OUT TIME*
>  
>  
> *and if there are 100 emplyees then do you want 100 sheets in the workbook
> *
> Yes. Newly created sheet would be as per the number of employees
>
> Thanks for your time
> Regards
> Rashid
>
> On Monday, December 31, 2012 7:07:48 AM UTC+4, Lalit Mohan Pandey wrote:
>>
>> Hi Rashid,
>>
>> I didn't find any employe name in the master sheet there is only two 
>> column No and Action and please tell me from where i will take in/out time. 
>> Didn't understand the data you   provided. Please check.
>>
>> Regards,
>> Lalit Mohan
>>
>> On Sunday, 30 December 2012 14:16:09 UTC+5:30, prkhan56 wrote:
>>>
>>> Hello Experts,
>>> Is this possible or not?
>>> I am reposting my query once again
>>> Regards
>>> Rashid Khan
>>> On Monday, December 24, 2012 10:58:15 AM UTC+4, prkhan56 wrote:
>>>
>>>> Hello Lalit
>>>> Thanks for the reply.
>>>> Please see the sample sheet which I have attached with my first post.  
>>>>  
>>>> The names of the employees are in excel sheet and the time in / time 
>>>> out details are shown against each employee name
>>>>  
>>>> I want to run the macro to run on Master sheet and create time sheet 
>>>> each employee showing their Time In/ Time Out
>>>>  
>>>> Is this clear?
>>>> Thanks 
>>>> Regards
>>>> Rashid Khan
>>>>  
>>>> On Monday, December 24, 2012 8:41:35 AM UTC+4, Lalit Mohan Pandey wrote:
>>>>
>>>>> Hi Rashid,
>>>>>
>>>>> Could you please explain when you want to run this process to capture 
>>>>> InTime and OutTime of an Employee and how we know who are the employees. 
>>>>> Is 
>>>>> there any list of employee?
>>>>>
>>>>> Regards,
>>>>> Lalit Mohan
>>>>>
>>>>> On Wednesday, 19 December 2012 16:17:43 UTC+5:30, prkhan56 wrote: 
>>>>>>
>>>>>>  Hello All                
>>>>>>
>>>>>> I am using excel 2007    
>>>>>>
>>>>>> I have data in the Master Sheet for various Employees  
>>>>>>
>>>>>> I want to create separate sheet for each employee viz A, B, C and so 
>>>>>> on    (see sample sheet attached)            
>>>>>>
>>>>>> I got the macro from the Group which create separate sheet for each 
>>>>>> name  (it is in the attached shet)     
>>>>>>
>>>>>>                 
>>>>>>
>>>>>> I wish to amend the macro so that it gives the output as shown in 
>>>>>> sample sheets A, B and C         
>>>>>>
>>>>>> My requirements are     
>>>>>>
>>>>>> 1              It should check the date/ time of each Employee and 
>>>>>> then put the values  (shown in Red Color) against each date Time-In 
>>>>>> / Time-Out on individual  sheets
>>>>>>
>>>>>> 2              The macro should take the first entry and the last 
>>>>>> entry for each day for each Name
>>>>>>
>>>>>> 3              It should do this till the last employee is reached
>>>>>>
>>>>>> 4              There are some unauthorized entry in Col D with no 
>>>>>> Names in Col A.  These entries should be ignored
>>>>>>
>>>>>> 5              The macro should put formulas in Col G and H 
>>>>>> (highlighted in Green Color)
>>>>>>
>>>>>> 6              Everything in Red Color Font would be done the by the 
>>>>>> macro…viz the Month, Name, Date, Time In and Time Out
>>>>>>
>>>>>>                 
>>>>>>
>>>>>> Thanks in advance
>>>>>> Rashid Khan
>>>>>>
>>>>>

-- 
Join official Facebook page of this forum @ 
https://www.facebook.com/discussexcel

FORUM RULES

1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get 
quick attention or may not be answered.
2) Don't post a question in the thread of another member.
3) Don't post questions regarding breaking or bypassing any security measure.
4) Acknowledge the responses you receive, good or bad.
5) Jobs posting is not allowed.
6) Sharing copyrighted material and their links is not allowed.

NOTE  : Don't ever post confidential data in a workbook. Forum owners and 
members are not responsible for any loss.
--- 
You received this message because you are subscribed to the Google Groups "MS 
EXCEL AND VBA MACROS" group.
To post to this group, send email to excel-macros@googlegroups.com.
To unsubscribe from this group, send email to 
excel-macros+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/excel-macros?hl=en.


Reply via email to