How to make match() work with date in excel vba?

后端 未结 6 771
萌比男神i
萌比男神i 2021-01-13 04:16

I\'m having problem making the match() work in excel VBA. The code is:

x = Application.Match(\"Sep 2008\", Range(\"F1:F1\"), 0)

The value i

6条回答
  •  南方客
    南方客 (楼主)
    2021-01-13 04:33

    I know this post is old, but I had the same issue, and did find the answer.

    To make it work, you first need to make VBA see the same data formatting as it appears in your excel spreadsheet :

    YourVar = Format("YourDate","mmm-yyyy") YourResult = Application.match(Clng(Cdate(YourVar)), YourRange, 0)

    Regards

    Gilles

提交回复
热议问题