Hi all,
I have attached my excel file with a macro that splits everything into daily data. The first sheet is my original data and the second is after I have run a macro.
This works fine until you go to row 148 on the second sheet. The Retailer Descriptions: Ttd Toffee and Ttd Van has started on the correct date, but then only appears every other two days, instead of everyday in the range provided. I have applied this to a large dataset and noticed the same problem always.
Any help would be greatly appreciated!
My VBA code:
Option Explicit
Sub ReformatData()
Dim LR As Long, Rw As Long, Dif As Long
Application.ScreenUpdating = False
'Setup
Sheets("Sheet1").Copy After:=Sheets(Sheets.Count)
ActiveSheet.Name = "Daily"
LR = Range("A" & Rows.Count).End(xlUp).Row
For Rw = LR To 2 Step -1
Dif = Range("B" & Rw) - Range("A" & Rw)
If Dif > 0 Then
Rows(Rw + 1).Resize(Dif).Insert xlShiftDown
With Range("A" & Rw + 1).Resize(Dif)
.FormulaR1C1 = "=R[-1]C + 1"
.NumberFormat = "YYYY/MM/DD"
End With
End If
Next Rw
Columns("B:B").Delete xlShiftToLeft
LR = Range("A" & Rows.Count).End(xlUp).Row
With Range("B1:C" & LR)
.SpecialCells(xlBlanks).FormulaR1C1 = "=R[-1]C"
.Value = .Value
End With
Range("A1").CurrentRegion.Sort Key1:=Range("A2"), Order1:=xlAscending, Header:=xlGuess
Application.ScreenUpdating = True
End Sub
Bookmarks