
如何根據(jù)Excel中的日期復(fù)制行并將其粘貼到另一個工作表?
假設(shè)我有一系列數(shù)據(jù),現(xiàn)在,我想根據(jù)特定日期復(fù)制整個行,然后將它們粘貼到另一張紙上。 您有什么好主意可以在Excel中處理此工作嗎?
根據(jù)今天的日期復(fù)制行并粘貼到另一張紙上
如果日期大于今天,則復(fù)制行并將其粘貼到另一張紙上
根據(jù)今天的日期復(fù)制行并粘貼到另一張紙上驚人的! 在 Excel 中使用高效的選項(xiàng)卡,如 Chrome、Firefox 和 Safari!每天節(jié)省50%的時間,并減少數(shù)千次鼠標(biāo)單擊!如果您需要復(fù)制日期為今天的行,請應(yīng)用以下VBA代碼:
1。 按住 ALT + F11 鍵打開 Microsoft Visual Basic應(yīng)用程序 窗口。
2。 點(diǎn)擊 插頁 > 模塊,然后將以下代碼粘貼到“模塊窗口”中。
VBA代碼:根據(jù)今天的日期復(fù)制和粘貼行:
Sub CopyRow()Updateby ExtendofficeDim xRgS As Range, xRgD As Range, xCell As RangeDim I As Long, xCol As Long, J As LongDim xVal As VariantOn Error Resume NextSet xRgS = Application.InputBox("Please select the date column:", "KuTools For Excel", Selection.Address, , , , , 8)If xRgS Is Nothing Then Exit SubSet xRgD = Application.InputBox("Please select a destination cell:", "KuTools For Excel", , , , , , 8)If xRgD Is Nothing Then Exit SubxCol = xRgS.Rows.CountSet xRgS = xRgS(1)Application.CutCopyMode = FalseJ = 0For I = 1 To xColSet xCell = xRgS.Offset(I - 1, 0)xVal = xCell.ValueIf TypeName(xVal) = "Date" And (xVal <> "") And (xVal = Date) ThenxCell.EntireRow.Copy xRgD.Offset(J, 0)J = J + 1End IfNextApplication.CutCopyMode = TrueEnd SubCopy3。 粘貼以上代碼后,請按 F5 鍵運(yùn)行此代碼,然后會彈出一個提示框,提醒您選擇要復(fù)制行的日期列,請參見屏幕截圖:
4。 然后點(diǎn)擊 OK 按鈕,在另一個提示框中,在另一個工作表中選擇要輸出結(jié)果的單元格,請參見屏幕截圖:
5。 然后點(diǎn)擊 OK 按鈕,現(xiàn)在,日期為今天的行立即粘貼到新工作表中,請參見屏幕截圖:
如果日期大于今天,則復(fù)制行并將其粘貼到另一張紙上要復(fù)制并粘貼日期大于或等于今天的行,例如,如果日期等于或大于今天5天,則將這些行復(fù)制并粘貼到另一張紙上。
以下VBA代碼可能會對您有所幫助:
1。 按住 ALT + F11 鍵打開 Microsoft Visual Basic應(yīng)用程序 窗口。
2。 點(diǎn)擊 插頁 > 模塊,然后將以下代碼粘貼到“模塊窗口”中。
VBA代碼:如果日期大于今天,則復(fù)制并粘貼行:
Sub CopyRow()Updateby ExtentofficeDim xRgS As Range, xRgD As Range, xCell As RangeDim I As Long, xCol As Long, J As LongDim xVal As VariantOn Error Resume NextSet xRgS = Application.InputBox("Please select the date column:", "KuTools For Excel", Selection.Address, , , , , 8)If xRgS Is Nothing Then Exit SubSet xRgD = Application.InputBox("Please select a destination cell:", "KuTools For Excel", , , , , , 8)If xRgD Is Nothing Then Exit SubxCol = xRgS.Rows.CountSet xRgS = xRgS(1)Application.CutCopyMode = FalseJ = 0For I = 1 To xColSet xCell = xRgS.Offset(I - 1, 0)xVal = xCell.ValueIf TypeName(xVal) = "Date" And (xVal <> "") And (xVal >= Date And (xVal < Date + 5)) ThenxCell.EntireRow.Copy xRgD.Offset(J, 0)J = J + 1End IfNextApplication.CutCopyMode = TrueEnd SubCopy備注:在上面的代碼中,您可以更改條件,例如小于今天或需要的天數(shù)。 如果TypeName(xVal)=“ Date”和(xVal <>“”)和(xVal> =日期和(xVal <日期+ 5))然后 腳本代碼。
3。 然后按 F5 鍵以運(yùn)行此代碼,請在提示框中,選擇要使用的數(shù)據(jù)列,請參見屏幕截圖:
4。 然后點(diǎn)擊 OK 按鈕,在另一個提示框中,在另一個工作表中選擇要輸出結(jié)果的單元格,請參見屏幕截圖:
5。 點(diǎn)擊 OK 按鈕,現(xiàn)在,日期等于或大于5天的行已被復(fù)制并粘貼到新表中,如以下屏幕截圖所示:
最佳辦公生產(chǎn)力工具
將小時轉(zhuǎn)化為分鐘 Kutools for Excel!準(zhǔn)備好增強(qiáng)您的 Excel 任務(wù)了嗎? 利用的力量 Kutools for Excel - 您終極的節(jié)省時間的工具。 簡化復(fù)雜的任務(wù)并像專業(yè)人士一樣瀏覽數(shù)據(jù)。 以閃電般的速度體驗(yàn) Excel!
為什么需要 Kutools for Excel

