VBA - Matching time in 2 different excel -
i match workbook1 (a2) time workbook2 (c4:c27) , return value of row.
workbook1 2:00 am
workbook2
12:00 1:00 2:00 3:00 4:00 5:00 6:00 7:00 8:00 9:00 10:00 11:00 12:00 pm 1:00 pm 2:00 pm 3:00 pm 4:00 pm 5:00 pm 6:00 pm 7:00 pm 8:00 pm 9:00 pm 10:00 pm 11:00 pm
below code
sub findmatchingvalue() dim integer dim intvaluetofind string dim mypath string dim wbksource workbook dim tm range dim ctm string set tm = thisworkbook.worksheets(1).range("a2") mypath = "c:\users\hlfoong\desktop\testing\" fn = dir(mypath & "pre*.xls") set wbksource = workbooks.open(mypath & fn) ctm = format(tm, "h:mm am/pm") intvaluetofind = ctm 'msgbox ("time " & ctm) = 4 27 if cells(i, 3).value = intvaluetofind msgbox ("found value on row " & i) exit sub end if next ' msgbox show if loop completes no success msgbox ("value not found in range!") end sub
but return value not found. kindly help.
Comments
Post a Comment