Dim d As Date
d = DateAdd("d", -1, Date)
Dim x As Range
Dim a As String
'Range("e1").Value = d
Columns("C:C").Select
a = Cells.Find(What:=d, After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Address
'Range(a).Offset(0, 31).Range("A1:B1").Select
'adjust this
' x = Range(a).Offset(0, 31).Range("A1:B1").Address
票数 1
EN
Stack Overflow用户
发布于
2017-04-13 12:45:54
尝试下面的代码(代码注释中的解释):
代码语言:
javascript
复制
Option Explicit
Sub FindYesterdaysDateRow()
Dim Rng As Range
Dim YesterD As Date
YesterD = DateAdd("d", -1, Date) ' <-- get yesterday's date
' the following line will work if you have column C formatted as "Date"
Set Rng = Range("C:C").Find(What:=YesterD, LookIn:=xlValues, LookAt:=xlWhole)
If Not Rng Is Nothing Then '<-- Find was successful
Range("A" & Rng.Row & ":I" & Rng.Row).Select