Please help. Vlookup thing..not sure

Closed
Pedie - May 3, 2010 at 01:13 PM
 Pedie - May 4, 2010 at 10:02 AM
Please help! I have a schedule@ which looks like this. In sheet1 A2:A13 has names of workers. B2:B30 has dates in serial wise. B3:S13 has the shift timings or text "L" for people on Leave and text "W off" for people on week offs. I want the formula to be entered in sheet1 A15 or macro.

1. When I run the formula/macro for the date example "4/3/2010" in the A15 or macro button, I want list of names comes in serial wise from A16.
2. Which means it will display the name of people who is present or will be present on that particular day.
Thanks a lot.

2 responses

rizvisa1 Posts 4478 Registration date Thursday January 28, 2010 Status Contributor Last seen May 5, 2022 766
May 3, 2010 at 01:23 PM
Why not just apply filter to see the list ?
0
I definitely can add filter but what i am actually trying to do to look up from other sheet....suppose if I have a wide range of data then it doesnt solve this problem
0
rizvisa1 Posts 4478 Registration date Thursday January 28, 2010 Status Contributor Last seen May 5, 2022 766
May 4, 2010 at 07:51 AM
Sorry, Now I am lost. Could you please upload a sample file with sample data etc on some shared site like https://authentification.site and post back here the link to allow better understanding of how it is now and how you foresee.
0
Sure please give me a moment
0
I have uploaded the file in this link http://myf1.webs.com/try.htm
Please click the sheet. In sheet 1 in C2 I want the formula or the macro that can give me a list of people present on particular date (when i eneter the date. I hope you understand, thanks alot.
0
Sorry i dont have access to "https://authentification.site " so I used the other site. Please solve this problem for me. Thanks alot.
0
rizvisa1 Posts 4478 Registration date Thursday January 28, 2010 Status Contributor Last seen May 5, 2022 766
May 4, 2010 at 09:52 AM
Not entirely sure how this search will occur. This should give you a good idea

Sub SearchSchedule()

Dim sScheduleSheet As String ' Name of schedule sheet
Dim sSearchSheet As String ' Name of search sheet

Dim lSchedNameStartRow As Long ' Row where the names on schedule sheet start

Dim iDateCol As Integer ' Column where the searched date is located on schedule sheet

Dim sSearchString As String ' The date entered on search sheet and is to be searched

Dim lScheduleRow As Long ' A row counter for schedule
Dim lSearchRow As Long ' A row counter for schedule

Dim sScheduleName As String ' the name scheduled
Dim sScheduleDate As String 'The value of schedule time

    sScheduleSheet = "Schedule" ' Name of schedule sheet
    sSearchSheet = "Sheet1" ' Name of search sheet

    lSchedNameStartRow = 6 ' Row where the names on schedule sheet start
    
    sSearchString = Sheets(sSearchSheet).Range("C2") ' The date entered on search sheet and is to be searched
    
    ' Column where the searched date is located on schedule sheet
    iDateCol = 0
    On Error Resume Next
        iDateCol = Sheets(sScheduleSheet).Cells.Find(sSearchString, Cells(1, 1), SearchOrder:=xlByRows, SearchDirection:=xlNext).Column
    On Error GoTo 0
    
    ' if the date is found
    If (iDateCol > 0) Then
        
        lScheduleRow = lSchedNameStartRow '
        lSearchRow = 2 '
        
        sScheduleName = Sheets(sScheduleSheet).Cells(lScheduleRow, "A")
        
        ' loop thru while the there is a non-blank column is encountered
        Do While (sScheduleData <> "")
            
            sScheduleDate = Sheets(sScheduleSheet).Cells(lScheduleRow, iDateCol)
            
            If ((sScheduleDate <> "L") And (sScheduleDate <> "WOFF")) Then
                
                Sheets(sSearchSheet).Cells(lSearchRow, "A") = sScheduleName
                lSearchRow = lSearchRow + 1
            
            End If
            
            'increase count by one
            lScheduleRow = lScheduleRow + 1
            
            sScheduleName = Sheets(sScheduleSheet).Cells(lScheduleRow, "A")
        Loop
    
    Else
    
        MsgBox ("Date " & sSearchString & " not found.")
        Exit Sub
    
    End If
    
End Sub
0
Rizvisa, thank you soo much....I have to study this..i hope this will work....
0