Woofy_McWoof_Woof
Board Regular
- Joined
- Oct 7, 2016
- Messages
- 60
- Office Version
- 365
- Platform
- Windows
Hi, I have thecode below which splits 24 hourly prices into 48 half hourly periods. Iwould like to do something similar whereby I take a daily figure and split thisinto 48 half hourly periods. I have tried altering it in different ways but nosuccess. Any ideas? Thanks for your help.
Column A = Date
Column B = Period
Column C = Price
Sub Split_Periods_v2()
Dim a As Variant, b As Variant
Dim i As Long, p As Long
a = Range("A2", Range("C" & Rows.Count).End(xlUp)).Value
ReDim b(1 To 2 * UBound(a), 1 To 3)
For i = 1 To UBound(a)
b(i * 2 - 1, 1) = a(i, 1): b(i * 2 - 1, 2) = i * 2 - 1 - p: b(i * 2 - 1, 3) = a(i, 3)
b(i * 2, 1) = a(i, 1): b(i * 2, 2) = i * 2 - p: b(i * 2, 3) = a(i, 3)
If i Mod 24 = 0 Then p = i * 2
Next i
Range("D2").Resize(UBound(b), 3).Value = b
Range("D1:F1").Value = Array("Date", "Period", "N2EX")
End Sub
Column A = Date
Column B = Period
Column C = Price
Sub Split_Periods_v2()
Dim a As Variant, b As Variant
Dim i As Long, p As Long
a = Range("A2", Range("C" & Rows.Count).End(xlUp)).Value
ReDim b(1 To 2 * UBound(a), 1 To 3)
For i = 1 To UBound(a)
b(i * 2 - 1, 1) = a(i, 1): b(i * 2 - 1, 2) = i * 2 - 1 - p: b(i * 2 - 1, 3) = a(i, 3)
b(i * 2, 1) = a(i, 1): b(i * 2, 2) = i * 2 - p: b(i * 2, 3) = a(i, 3)
If i Mod 24 = 0 Then p = i * 2
Next i
Range("D2").Resize(UBound(b), 3).Value = b
Range("D1:F1").Value = Array("Date", "Period", "N2EX")
End Sub