VBA - "Find" with "where"

Kr4ft

New Member
Joined
Aug 12, 2014
Messages
2
Hello there guys! First, thank you for your community and everyone inside of it! And sorry... probably my english is not perfect...

So... I need to create a way to do a "find" with a "where" on it... let's say... "Find Date where ID = Me"
The thing is: I need to find a registry in a table and then insert an information on it!


Like this:

xABCDE
1NameDateInOutTotal
2Alex12/12/201412:0018:006:00
3Joana12/12/201408:0018:0010:00
4Michel13/12/201409:00
5Joana13/12/201409:34

<tbody>
</tbody>


So, let's say Joana wants to leave and press the "create mark" buttom... so it must find her name, then the date, then the line and then insert the hour in column D

Preetty easy huh?

Or.... if you guys find another way to do it... please let me know! I tought about filters but... since VBA does not understand a filter... it kind of didn't work... Probably there is a way but i'm too "starter edition" to know that kind of advanced alien technology

So anyway! Thanks everyone!

Kind Regards,

Kr4ft
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Maybe a loop using For?

Like, select A4569128756981659811²³¹²³¹²³¹²3¢²³£¬³²¬ , vlookup, then a backwards loop searching 10 entries?
first line, see date is = today? yes then look name, is the same guy? yes, then insert out...
Any toughts?
 
Upvote 0
First of all really don't understand post #2 but anyway...

possibly an old fashioned, inefficient way...
First create a dropdown with the names in a cell so they can select their name (in this case cell J1) then assign the code below to the button.

Rich (BB code):
Sub test()
    Dim c As Range
    For Each c In Range("A2:A" & Range("A" & Rows.Count).End(xlUp).Row)
        
        If c.Value = Range("J1").Value Then
            
            If c.Offset(0, 1) = Date Then
                If Len(c.Offset(0, 2)) = 0 Then
                    c.Offset(0, 2) = Format(Now(), "hh:mm")
                Else
                    If Len(c.Offset(0, 2)) > 0 And Len(c.Offset(0, 3)) = 0 Then c.Offset(0, 3) = Format(Now(), "hh:mm")
                End If
            End If
        
        End If
        
        If Len(c.Offset(0, 2)) > 0 And Len(c.Offset(0, 3)) > 0 Then
            c.Offset(0, 4) = c.Offset(0, 3) - c.Offset(0, 2)
            c.Offset(0, 4).NumberFormat = "[hh]:mm"
        End If
    Next
End Sub

since VBA does not understand a filter
by the way VBA understands a filter perfectly well
 
Upvote 0

Forum statistics

Threads
1,215,507
Messages
6,125,212
Members
449,214
Latest member
mr_ordinaryboy

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