首页 > 解决方案 > Find a date which is represented with a formula

问题描述

I assign the 1st January to cell A1. The cell formula bar displays:
01/01/2020

The cell is then formatted as Custom:
ddd", "ddmmm
So the cell displays:
Wed, 01Jan

I can use the following code to select the cell A1 (1st Jan):

ActiveSheet.Cells.Find(#1/1/2020#, , lookat:=xlWhole).Select

I assign the 2nd of Jan to cell A4. Cell A4 is formatted the same custom way and the formula bar displays:
A1+1

The cell displays:
Thu, 02Jan

When searching for the 2nd of Jan i'm getting Run-time error '91': Object variable or With block variable not set error, when I run the macro as:

ActiveSheet.Cells.Find(#2/1/2020#, , lookat:=xlWhole).Select

How can I correct the macro to find and select cell A4 that represents the cell for 2nd Jan?

标签: excelvba

解决方案


你可以试试这个

  • 在数据表中执行 ctrl+F
  • 点击选项<<
  • 设置查找范围:值

在此处输入图像描述


推荐阅读