Search & return results with latest datestamp

Scoti

New Member
Joined
Nov 8, 2020
Messages
39
Office Version
  1. 2010
Platform
  1. Windows
fibder.txtHi all,
I am currently running a workbook which tracks various items through a process. I have tabs for each step of the
process where the items are logged in and then out of before being sent to the next process. I have a macro which allows me to search for an item and tell me where exactly it is in the process however it is not providing me with the last "movement" or latest timestamp. In this macro the item will appear in sheets Man_Completed, Man_Received, Completed, & Received but I just need the info returned from the sheet containing the latest timestamp for that particular item. Does that make sense?
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
You can supply your code instead of creating a link to the file that has your code.

1608462945471.png
 
Upvote 0
Sub findSample()

Dim FindString As String

Dim Rng As Range

Set Sheet = Sheets("Retest")

Application.ScreenUpdating = False

For Each cell In Range("C2:C50")

FindString = cell.Value





With Sheets("Man_Completed").Range("C:C")

Set Rng = .Find(What:=FindString, _

After:=.Cells(.Cells.Count), _

LookIn:=xlValues, _

LookAt:=xlWhole, _

SearchOrder:=xlByRows, _

SearchDirection:=xlNext, _

MatchCase:=False)



If Not Rng Is Nothing Then

Application.Goto Rng, True



TheDepartment = ActiveCell.Offset(0, 2).Value

TheDate = ActiveCell.Offset(0, 3).Value



cell.Offset(0, 12).Value = TheDepartment

cell.Offset(0, 13).Value = TheDate





End If

End With

With Sheets("Man_Received").Range("D:D")

Set Rng = .Find(What:=FindString, _

After:=.Cells(.Cells.Count), _

LookIn:=xlValues, _

LookAt:=xlWhole, _

SearchOrder:=xlByRows, _

SearchDirection:=xlNext, _

MatchCase:=False)

If Not Rng Is Nothing Then

Application.Goto Rng, True



TheDepartment = ActiveCell.Offset(0, -2).Value

TheDate = ActiveCell.Offset(0, -1).Value



cell.Offset(0, 12).Value = TheDepartment

cell.Offset(0, 13).Value = TheDate





End If

End With

Sheet.Activate





With Sheets("Completed").Range("C:C")

Set Rng = .Find(What:=FindString, _

After:=.Cells(.Cells.Count), _

LookIn:=xlValues, _

LookAt:=xlWhole, _

SearchOrder:=xlByRows, _

SearchDirection:=xlNext, _

MatchCase:=False)



If Not Rng Is Nothing Then

Application.Goto Rng, True



TheDepartment = ActiveCell.Offset(0, 2).Value

TheDate = ActiveCell.Offset(0, 3).Value



cell.Offset(0, 12).Value = TheDepartment

cell.Offset(0, 13).Value = TheDate





End If

End With

With Sheets("Received").Range("D:D")

Set Rng = .Find(What:=FindString, _

After:=.Cells(.Cells.Count), _

LookIn:=xlValues, _

LookAt:=xlWhole, _

SearchOrder:=xlByRows, _

SearchDirection:=xlNext, _

MatchCase:=False)

If Not Rng Is Nothing Then

Application.Goto Rng, True



TheDepartment = ActiveCell.Offset(0, -2).Value

TheDate = ActiveCell.Offset(0, -1).Value



cell.Offset(0, 12).Value = TheDepartment

cell.Offset(0, 13).Value = TheDate





End If

End With

Sheet.Activate

Next

End Sub
 
Upvote 0

Forum statistics

Threads
1,215,487
Messages
6,125,085
Members
449,206
Latest member
ralemanygarcia

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