using vba or excel find the first reference match

noufi

New Member
Joined
Dec 19, 2018
Messages
6
hi guys,
i would like to ask how can i resolve this.....

Below is my actual data.

date time temp
1 10/7/2019 0:12 120.3
2 10/7/2019 0:13 119.5
3 10/7/2019 0:13 121.3
4 10/7/2019 0:13 120
5 10/7/2019 0:13 121.2
6 10/7/2019 0:13 120
7 10/7/2019 0:13 121.1
8 10/7/2019 0:14 120.6
i have a cutoff or reference value in j3,( eg.. 121). once it happens, then i need k3 to be 10/7/2019 0:13(3 10/7/2019 0:13 121.3)
how can this happen...can somebody help me on this..
i used lookup....LOOKUP(J3, C8:C1000, B8:B1000)
but it showing last cell value that is cell 7.
also lookup value function is not working when i change the data ....

i want to find the date time(column 1) of reference value given in j3 (temp, column 2) either in excel or vba excel
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Copy this formula in K3

=TEXT(INDIRECT("B"&MATCH(TRUE,C1:C8>J3,0)),"mm/d/yyy") & " " & TEXT(INDIRECT("C"&MATCH(TRUE,C1:C8>J3,0)),"h:m")

It is an array formula so you will need to enter it by selecting CTL SHFT ENTER.

You will also have to adjust the C1:C8 range in the formula to fit your data
 
Last edited:
Upvote 0
thanks for ur reply....

i tried below vba code....it is giving me the search value in column c....
how can i get the corresponding value in column b

Private Sub CommandButton4_Click()
Dim b As Long
With Worksheets(1).Range("c8:c5000")
Set c = .Find(b, LookIn:=xlValues)
If Not c Is Nothing Then
'firstAddress = c.Address
firstvalue = c.Value
Range("o2").Value = c.Value
'MsgBox c.Address
'Set c = .FindNext(c)
'Loop While Not c Is Nothing
End If
End With
end sub

once i run the code output is: 120.3
$c$87(in msgbox)

but i want $b$87 value......
looking fwd to hearing from u soon....
 
Upvote 0

Forum statistics

Threads
1,214,584
Messages
6,120,385
Members
448,956
Latest member
JPav

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