chipsworld
Board Regular
- Joined
- May 23, 2019
- Messages
- 169
- Office Version
- 365
Good day all,
Need your help once again.
I found the base code from the below on the web and thought it would work, but apparently I need some morre help.
The original code worked great for two variables, but in order to do what I need to do, I need a third.
The issue is if the second variable occurs more than once, it will always go to that instance and not look for another one.
Here is what I have...I'm sure someone out there can make sense of it.
The parts in red are my add in attempt to include a third variable.
As you can probably tell, the whole idea is to capture the date and time someone returns an item and put that date/time into the line where they checked it out.
The code works beautifully without my changes if the item being checked out is only checked out once. ITs that second, third, etc that kill it...
Need your help once again.
I found the base code from the below on the web and thought it would work, but apparently I need some morre help.
The original code worked great for two variables, but in order to do what I need to do, I need a third.
The issue is if the second variable occurs more than once, it will always go to that instance and not look for another one.
Here is what I have...I'm sure someone out there can make sense of it.
The parts in red are my add in attempt to include a third variable.
As you can probably tell, the whole idea is to capture the date and time someone returns an item and put that date/time into the line where they checked it out.
The code works beautifully without my changes if the item being checked out is only checked out once. ITs that second, third, etc that kill it...
VBA Code:
Private Sub INBOUND()
Dim rngFound As Range
Dim strFirst As String
Dim strNam As String
Dim strAsset As String
Dim rw As Long
Dim timestmp As String
Dim ws As Worksheet
Dim strtimo As String
Set ws = ThisWorkbook.Worksheets("ASSET Loging")
timestmp = Now
strNam = Me.txtnam.Value
strAsset = Me.cmbasstype.Value
strtimo = Me.txtdat.Value
With ws
Set rngFound = .Columns("C").Find(strNam, Cells(Rows.Count, "C"), xlValues, xlWhole)
If Not rngFound Is Nothing Then
strFirst = rngFound.Address
Do
If LCase(.Cells(rngFound.Row, "A").Text) = LCase(strAsset) [B][COLOR=rgb(226, 80, 65)]And LCase(.Cells(rngFound.Row, "E").Text) = LCase(strtimo) [/COLOR][/B]Then
'Found a match
rw = rngFound.Row
If ws.Cells(rw, "F").Value = "" Then
ws.Cells(rw, "F").Value = timestmp
Else: MsgBox "This item has already been marked as returned!", vbOKOnly
Exit Sub
End If
End If
Set rngFound = .Columns("C").Find(strNam, rngFound, xlValues, xlWhole)
Loop While rngFound.Address <> strFirst
End If
End With
MsgBox "Item has been marked as received!", vbOKOnly
Set rngFound = Nothing
End Sub