Search column for value and count number of rows

醉酒当歌 提交于 2019-12-13 23:28:53

问题


I have a large workbook that contains a list of dates in column "A" of Sheet1. Is there a way to search the column for a specific date, count how many rows down it is, then set that number as a variable that I can use in a range in the next bit of VBA code?

Basically, I want to be able to find the row number associated with the date, then reference that row later on.


回答1:


Here you go...

Dim MyDate&, TheRow&
MyDate = DateSerial(2015, 4, 11)
TheRow = Application.Match(MyDate, Sheet1.[a:a], 0)


来源:https://stackoverflow.com/questions/33487865/search-column-for-value-and-count-number-of-rows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!