ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Search column for date format; cut and paste multiple cells to row above (https://www.excelbanter.com/excel-programming/449125-search-column-date-format%3B-cut-paste-multiple-cells-row-above.html)

MaryGHunter

Search column for date format; cut and paste multiple cells to row above
 
I need a macro that searches column B for any cells with a date format (any date format). If true, I need cells (B:F) (in the same row), to be cut and pasted to the row above in columns (D:H). Then I need that original row to be deleted.

I have found a few macros and functions that are similare but none that work for what I need.

I would greatly appreciate any help anyone can give!

Auric__

Search column for date format; cut and paste multiple cells to row above
 
MaryGHunter wrote:

I need a macro that searches column B for any cells with a date format
(any date format). If true, I need cells (B:F) (in the same row), to be
cut and pasted to the row above in columns (D:H). Then I need that
original row to be deleted.

I have found a few macros and functions that are similare but none that
work for what I need.

I would greatly appreciate any help anyone can give!


Test this against a *copy* of your data; don't test against live data.

Sub findDatesCopyAndKill()
For L0 = 2 To Cells.SpecialCells(xlCellTypeLastCell).Row
If IsDate(Cells(L0, 2).Value) Then
Range("B" & L0 & ":F" & L0).Copy Range("D" & L0 - 1)
Rows(L0).Delete
L0 = L0 - 1
End If
Next
End Sub

--
The siren sings a lonely song of all the wants and hungers...


All times are GMT +1. The time now is 10:13 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com