Excel VBA - cannot .find date string in range

前端 未结 2 1412
我在风中等你
我在风中等你 2021-01-23 05:49

I wrote some VBA script to search a range of dates in a list, it can find the dates, but for some reason it cannot match them to the target range. I tested the target range wit

2条回答
  •  滥情空心
    2021-01-23 06:11

    Using FIND with dates is finnicky, see here

    Your code worked on my tested when I changed

    Set TargetColumnRange = dumpsheet.Range("G2:G" & TargetValue).Find(what:=SourceColumnValue, _
                                                               LookIn:=xlFormulas, _
                                                               LookAt:=xlWhole, _
                                                               SearchOrder:=xlByRows)
    

    to

    Set TargetColumnRange = dumpsheet.Range("G2:G" & TargetValue).Find(what:=DATEVALUE(SourceColumnValue), _
                                                               LookIn:=xlFormulas, _
                                                               LookAt:=xlWhole, _
                                                               SearchOrder:=xlByRows)
    

提交回复
热议问题