DynamiteHack
Board Regular
- Joined
- Jan 14, 2012
- Messages
- 60
I have run into a bit of a wall with this one...I have a list of items that were printed and a date timestamp on each line. My goal is to scan down the rows and insert 3 blank rows after each date change.
I have found a way to insert a blank row after unique values. Code is below. ..
Unfortunately, this code inserts a blank row after every line because of the time portion of the stamp and I believe it is compared to the data in column A. This isn't exactly what I'm trying to do, but it got me closer. The trouble that I'm having is figuring out a strategy of looking at just the date portion of the stamp and inserting the blank rows between different dates. Here is a snippet of data, any advice would be much appreciated!!
[TABLE="width: 336"]
<tbody>[TR]
[TD="width: 88"]PickList[/TD]
[TD="width: 88"]GOOD[/TD]
[TD="class: xl65, width: 160, align: right"]10/6/2014 16:49[/TD]
[/TR]
[TR]
[TD]PickList[/TD]
[TD]GOOD[/TD]
[TD="class: xl65, align: right"]10/6/2014 16:49[/TD]
[/TR]
[TR]
[TD]PickList[/TD]
[TD]GOOD[/TD]
[TD="class: xl65, align: right"]10/6/2014 16:49[/TD]
[/TR]
[TR]
[TD]PickList[/TD]
[TD]GOOD[/TD]
[TD="class: xl65, align: right"]10/6/2014 16:49[/TD]
[/TR]
[TR]
[TD]PickList[/TD]
[TD]GOOD[/TD]
[TD="class: xl65, align: right"]10/6/2014 16:49[/TD]
[/TR]
[TR]
[TD]PickList[/TD]
[TD]GOOD[/TD]
[TD="class: xl65, align: right"]10/7/2014 9:00[/TD]
[/TR]
[TR]
[TD]PickList[/TD]
[TD]GOOD[/TD]
[TD="class: xl65, align: right"]10/7/2014 9:00[/TD]
[/TR]
[TR]
[TD]PickList[/TD]
[TD]GOOD[/TD]
[TD="class: xl65, align: right"]10/7/2014 9:00[/TD]
[/TR]
[TR]
[TD]PickList[/TD]
[TD]GOOD[/TD]
[TD="class: xl65, align: right"]10/7/2014 9:00[/TD]
[/TR]
[TR]
[TD]PickList[/TD]
[TD]GOOD[/TD]
[TD="class: xl65, align: right"]10/7/2014 9:00[/TD]
[/TR]
[TR]
[TD]PickList[/TD]
[TD]GOOD[/TD]
[TD="class: xl65, align: right"]10/7/2014 9:00[/TD]
[/TR]
</tbody>[/TABLE]
I have found a way to insert a blank row after unique values. Code is below. ..
Code:
Sub insertem()
Dim r As Long
For r = Cells(Rows.Count, "A").End(xlUp).Row To 2 Step -1
If range("J" & r).Value <> range("J" & r - 1) Then
Rows(r).Insert
End If
Next r
End Sub
Unfortunately, this code inserts a blank row after every line because of the time portion of the stamp and I believe it is compared to the data in column A. This isn't exactly what I'm trying to do, but it got me closer. The trouble that I'm having is figuring out a strategy of looking at just the date portion of the stamp and inserting the blank rows between different dates. Here is a snippet of data, any advice would be much appreciated!!
[TABLE="width: 336"]
<tbody>[TR]
[TD="width: 88"]PickList[/TD]
[TD="width: 88"]GOOD[/TD]
[TD="class: xl65, width: 160, align: right"]10/6/2014 16:49[/TD]
[/TR]
[TR]
[TD]PickList[/TD]
[TD]GOOD[/TD]
[TD="class: xl65, align: right"]10/6/2014 16:49[/TD]
[/TR]
[TR]
[TD]PickList[/TD]
[TD]GOOD[/TD]
[TD="class: xl65, align: right"]10/6/2014 16:49[/TD]
[/TR]
[TR]
[TD]PickList[/TD]
[TD]GOOD[/TD]
[TD="class: xl65, align: right"]10/6/2014 16:49[/TD]
[/TR]
[TR]
[TD]PickList[/TD]
[TD]GOOD[/TD]
[TD="class: xl65, align: right"]10/6/2014 16:49[/TD]
[/TR]
[TR]
[TD]PickList[/TD]
[TD]GOOD[/TD]
[TD="class: xl65, align: right"]10/7/2014 9:00[/TD]
[/TR]
[TR]
[TD]PickList[/TD]
[TD]GOOD[/TD]
[TD="class: xl65, align: right"]10/7/2014 9:00[/TD]
[/TR]
[TR]
[TD]PickList[/TD]
[TD]GOOD[/TD]
[TD="class: xl65, align: right"]10/7/2014 9:00[/TD]
[/TR]
[TR]
[TD]PickList[/TD]
[TD]GOOD[/TD]
[TD="class: xl65, align: right"]10/7/2014 9:00[/TD]
[/TR]
[TR]
[TD]PickList[/TD]
[TD]GOOD[/TD]
[TD="class: xl65, align: right"]10/7/2014 9:00[/TD]
[/TR]
[TR]
[TD]PickList[/TD]
[TD]GOOD[/TD]
[TD="class: xl65, align: right"]10/7/2014 9:00[/TD]
[/TR]
</tbody>[/TABLE]