我想根據列A中的值複製整個行。條件將是昨天的日期。宏需要保持動態,因爲每天這個宏將運行並使用前一天的數據。這是我到目前爲止:基於單元格的值選擇行並將它們粘貼到新工作表excel vba
Sub SelectRowsByDate()
Dim WS1 As Worksheet
Set WS1 = ThisWorkbook.Sheets("Test")
Dim YesterdayDate As Date
Dim loopCounter As Long
YesterdayDate = Date - 1
For loopCounter = 1 To Rows.Count
If Cells(i, 1).Value = YesterdayDate Then
Rows(i).Select
End If
End Sub
請不要在MS Office或VBA中使用[宏]。 [宏標記wiki](http://stackoverflow.com/tags/macros/info) –
你能指定什麼不工作? – Alex
是的,我陷入了If語句。我也不確定如何選擇行後將其複製到不同的工作表。 謝謝! – stanjo