+ Reply to Thread
Results 1 to 5 of 5

how can i search and copy details of a particular User details in Sheet1

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    03-01-2014
    Location
    Mysore
    MS-Off Ver
    Excel 2007
    Posts
    379

    how can i search and copy details of a particular User details in Sheet1

    i have 12 sheets in my excel i have taken sheet1(destination) in that i used to display particular user data(details) with headers

    i have created an macro called searchcopy

    what i was trying to it should display Month name(Which Month they have taken a leave
    following this columns
    TOTAL PRESENTS
    TOTAL WEEKLY OFF
    TOTAL LEAVES
    TOTAL ABSENTS
    TOTAL HALFDAY
    TOTAL PRESENT


    i have attached My ExcelSheet.....Please help me


     Dim Name As Variant
        Dim FindName As Variant
        Dim ws As Worksheet
        Set ws = Worksheets("May_2014")
        Name = InputBox(Prompt:="Please Enter the Application Name", _
            Title:=" Application Search")
        If Name = "" Then Exit Sub
        
        With ActiveSheet.Range("b2:fa65536")
            Set FindName = .Find(Name, , , xlWhole)
            If Not FindName Is Nothing Then
                
                MsgBox FindName.EntireRow.Cells(1, 1).Value
                MsgBox FindName.Address
            Else
                MsgBox Prompt:="Name Not Found.", Title:="Search Failed"
                Exit Sub
            End If
        End With
    Attached Files Attached Files

  2. #2
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,649

    Re: how can i search and copy details of a particular User details in Sheet1

    You may try this worksheet change event code to get the desired output.
    Private Sub Worksheet_Change(ByVal Target As Range)
    Dim ws As Worksheet
    Dim rng As Range
    Dim lr As Long, r As Long
    If Target.Count > 1 Then Exit Sub
    If Not Intersect(Target, Range("H6")) Is Nothing Then
    With Range("I14:I19")
        .Interior.ColorIndex = 6
        .ClearContents
    End With
    Application.EnableEvents = False
        If Target.Offset(3, 0) <> "Enter Employee Name" Then
            For Each ws In Worksheets
                If ws.Name <> "Summary" And WorksheetFunction.Text(ws.Range("Af2").Value, "mmmm") = Target Then
                    On Error Resume Next
                    r = WorksheetFunction.Match(Target.Offset(3, 0), ws.Range("B:B"), 0)
                    On Error GoTo 0
                    If r > 0 Then
                        Range("I14").Value = ws.Cells(r, "AJ")
                        Range("I15").Value = ws.Cells(r, "AK")
                        Range("I16").Value = ws.Cells(r, "AL")
                        Range("I17").Value = ws.Cells(r, "AM")
                        Range("I18").Value = ws.Cells(r, "AN")
                        Range("I19").Value = ws.Cells(r, "AO")
                        Application.EnableEvents = True
                        Exit Sub
                    Else
                        MsgBox "Employee not found for this month"
                        Application.EnableEvents = True
                        Exit Sub
                    End If
                End If
            Next ws
        End If
    End If
    If Not Intersect(Target, Range("H9")) Is Nothing Then
    With Range("I14:I19")
        .Interior.ColorIndex = 6
        .ClearContents
    End With
    Application.EnableEvents = False
        If Target.Offset(-3, 0) <> "Enter Month" Then
            For Each ws In Worksheets
                If ws.Name <> "Summary" And WorksheetFunction.Text(ws.Range("Af2").Value, "mmmm") = Target.Offset(-3, 0) Then
                    On Error Resume Next
                    r = WorksheetFunction.Match(Target, ws.Range("B:B"), 0)
                    On Error GoTo 0
                    If r > 0 Then
                        Range("I14").Value = ws.Cells(r, "AJ")
                        Range("I15").Value = ws.Cells(r, "AK")
                        Range("I16").Value = ws.Cells(r, "AL")
                        Range("I17").Value = ws.Cells(r, "AM")
                        Range("I18").Value = ws.Cells(r, "AN")
                        Range("I19").Value = ws.Cells(r, "AO")
                        Application.EnableEvents = True
                        Exit Sub
                    Else
                        MsgBox "Employee not found for this month"
                        Application.EnableEvents = True
                        Exit Sub
                    End If
                End If
            Next ws
        End If
    End If
    Application.EnableEvents = True
    End Sub
    Please find the attached sheet and just change either the Month or Employee to get the desired output in the yellow cells.
    Is this what you are trying to achieve?
    Attached Files Attached Files
    Regards
    sktneer


    Treat people the way you want to be treated. Talk to people the way you want to be talked to.
    Respect is earned NOT given.

  3. #3
    Forum Contributor
    Join Date
    03-01-2014
    Location
    Mysore
    MS-Off Ver
    Excel 2007
    Posts
    379

    Re: how can i search and copy details of a particular User details in Sheet1

    tanks for u r knowledge its working

    sorry for it

    i wanted if i want to display in summary seet only selected mont list data
    Last edited by baig123; 10-10-2014 at 01:04 AM. Reason: paragrap

  4. #4
    Forum Contributor
    Join Date
    03-01-2014
    Location
    Mysore
    MS-Off Ver
    Excel 2007
    Posts
    379

    Re: how can i search and copy details of a particular User details in Sheet1

    i ave more tan 50 employee but in validation not taking more tan 15 values

  5. #5
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,649

    Re: how can i search and copy details of a particular User details in Sheet1

    I have created a list of Employees in col. AA and then created a dynamic drop down list referencing the list in col. AA. You can replace this list in Col. AA with your real employee names. If you add any name in this list in future, that name will be included in the drop down list of employees in H9 automatically.

    If that takes care of your question, please mark your thread as Solved by selecting Thread Tools (just above your first post) --> Mark thread as solved.
    Moreover you may also click on * (star) to Add Reputation if the solution provided helped you.
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Search unique value from one worksheet in another & copy details - macro
    By ccjg96 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-04-2014, 07:01 AM
  2. Search and paste corresponding details
    By haddo in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 08-22-2013, 04:20 AM
  3. [SOLVED] copy details in sheet3,d8 into sheet1,e10. there are 48 sheet.
    By sand takagi in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 11-06-2012, 12:33 PM
  4. Replies: 0
    Last Post: 08-21-2012, 01:19 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1