Skip to main content
Stack Overflow
  1. About
  2. For Teams

Return to Question

Post Timeline

edited tags
Link
Dharman
  • 34k
  • 27
  • 105
  • 156

Transform hourly data in minute timestep data - Solved

I have an Excel file with hourly data, that is 8760 values on one year.
I need to have data at the minute-step.
I need to take the hourly value, and copy it to the 60 cells over and over again, until I have 525 600 values, being my minute timestep.

I'veI tried a couple things already, but haven't been able to do anything else than copy/paste it by hand, which is going to take long...


Sub test()
Worksheets("MySheet").Activate
Dim i As Double 'minutes increment
Dim j As Integer 'hourly increment
Dim k As Double
k = 0 'initialization of k
Dim Var1 As Single
Dim Var2 As Single
 For j = 1 To 8760
 Var1 = Cells(j, 8).Value 'Row "j"/from 1 to 8760, column "8"/H --> hourly values
 Var2 = Cells(j, 7).Value 'Row "j"/from 1 to 60, column "7"/G --> minutes values
 For i = 1 To 60
 
 k = k + 1 'incrementation of k to be able to insert the values in the 60 cells (corresponding to 60 minutes)
 Cells(k + 3, 10) = Var1 'insert those values in the 10th column (J) 
 Cells(k + 3, 9) = Var2 'insert those values in the 10th column (I)
 
 Next i
 Next j 
End Sub
Sub test()
Worksheets("MySheet").Activate
Dim i As Double 'minutes increment
Dim j As Integer 'hourly increment
Dim k As Double
k = 0 'initialization of k
Dim Var1 As Single
Dim Var2 As Single
 For j = 1 To 8760
 Var1 = Cells(j, 8).Value 'Row "j"/from 1 to 8760, column "8"/H --> hourly values
 Var2 = Cells(j, 7).Value 'Row "j"/from 1 to 60, column "7"/G --> minutes values
 For i = 1 To 60
 
 k = k + 1 'incrementation of k to be able to insert the values in the 60 cells (corresponding to 60 minutes)
 Cells(k + 3, 10) = Var1 'insert those values in the 10th column (J) 
 Cells(k + 3, 9) = Var2 'insert those values in the 10th column (I)
 
 Next i
 Next j 
End Sub

This can also be done without VBA, as given in answer, with the function =INDEX.

Thanks for your help !

Transform hourly data in minute timestep data - Solved

I have an Excel file with hourly data, that is 8760 values on one year. I need to have data at the minute-step. I need to take the hourly value, and copy it to the 60 cells over and over again, until I have 525 600 values, being my minute timestep.

I've tried a couple things already, but haven't been able to do anything else than copy/paste it by hand, which is going to take long...


Sub test()
Worksheets("MySheet").Activate
Dim i As Double 'minutes increment
Dim j As Integer 'hourly increment
Dim k As Double
k = 0 'initialization of k
Dim Var1 As Single
Dim Var2 As Single
 For j = 1 To 8760
 Var1 = Cells(j, 8).Value 'Row "j"/from 1 to 8760, column "8"/H --> hourly values
 Var2 = Cells(j, 7).Value 'Row "j"/from 1 to 60, column "7"/G --> minutes values
 For i = 1 To 60
 
 k = k + 1 'incrementation of k to be able to insert the values in the 60 cells (corresponding to 60 minutes)
 Cells(k + 3, 10) = Var1 'insert those values in the 10th column (J) 
 Cells(k + 3, 9) = Var2 'insert those values in the 10th column (I)
 
 Next i
 Next j 
End Sub

This can also be done without VBA, as given in answer, with the function =INDEX.

Thanks for your help !

Transform hourly data in minute timestep data

I have an Excel file with hourly data, that is 8760 values on one year.
I need to have data at the minute-step.
I need to take the hourly value, and copy it to the 60 cells over and over again, until I have 525 600 values, being my minute timestep.

I tried a couple things, but haven't been able to do anything.

Sub test()
Worksheets("MySheet").Activate
Dim i As Double 'minutes increment
Dim j As Integer 'hourly increment
Dim k As Double
k = 0 'initialization of k
Dim Var1 As Single
Dim Var2 As Single
 For j = 1 To 8760
 Var1 = Cells(j, 8).Value 'Row "j"/from 1 to 8760, column "8"/H --> hourly values
 Var2 = Cells(j, 7).Value 'Row "j"/from 1 to 60, column "7"/G --> minutes values
 For i = 1 To 60
 
 k = k + 1 'incrementation of k to be able to insert the values in the 60 cells (corresponding to 60 minutes)
 Cells(k + 3, 10) = Var1 'insert those values in the 10th column (J) 
 Cells(k + 3, 9) = Var2 'insert those values in the 10th column (I)
 
 Next i
 Next j 
End Sub

This can also be done without VBA, as given in answer, with the function =INDEX.

added 86 characters in body
Source Link

I have an Excel file with hourly data, that is 8760 values on one year. I need to have data at the minute-step. I need to take the hourly value, and copy it to the 60 cells over and over again, until I have 525 600 values, being my minute timestep.

I've tried a couple things already, but haven't been able to do anything else than copy/paste it by hand, which is going to take long...


Update/Solution :

Sub test()
Worksheets("MySheet").Activate
Dim i As Double 'minutes increment
Dim j As Integer 'hourly increment
Dim k As Double
k = 0 'initialization of k
Dim Var1 As Single
Dim Var2 As Single
 For j = 1 To 8760
 Var1 = Cells(j, 8).Value 'Row "j"/from 1 to 8760, column "8"/H --> hourly values
 Var2 = Cells(j, 7).Value 'Row "j"/from 1 to 60, column "7"/G --> minutes values
 For i = 1 To 60
 
 k = k + 1 'incrementation of k to be able to insert the values in the 60 cells (corresponding to 60 minutes)
 Cells(k + 3, 10) = Var1 'insert those values in the 10th column (J) 
 Cells(k + 3, 9) = Var2 'insert those values in the 10th column (I)
 
 Next i
 Next j 
End Sub

This can also be done without VBA, as given in answer, with the function =INDEX.

Thanks for your help !

I have an Excel file with hourly data, that is 8760 values on one year. I need to have data at the minute-step. I need to take the hourly value, and copy it to the 60 cells over and over again, until I have 525 600 values, being my minute timestep.

I've tried a couple things already, but haven't been able to do anything else than copy/paste it by hand, which is going to take long...


Update/Solution :

Sub test()
Worksheets("MySheet").Activate
Dim i As Double 'minutes increment
Dim j As Integer 'hourly increment
Dim k As Double
k = 0 'initialization of k
Dim Var1 As Single
Dim Var2 As Single
 For j = 1 To 8760
 Var1 = Cells(j, 8).Value 'Row "j"/from 1 to 8760, column "8"/H --> hourly values
 Var2 = Cells(j, 7).Value 'Row "j"/from 1 to 60, column "7"/G --> minutes values
 For i = 1 To 60
 
 k = k + 1 'incrementation of k to be able to insert the values in the 60 cells (corresponding to 60 minutes)
 Cells(k + 3, 10) = Var1 'insert those values in the 10th column (J) 
 Cells(k + 3, 9) = Var2 'insert those values in the 10th column (I)
 
 Next i
 Next j 
End Sub

Thanks for your help !

I have an Excel file with hourly data, that is 8760 values on one year. I need to have data at the minute-step. I need to take the hourly value, and copy it to the 60 cells over and over again, until I have 525 600 values, being my minute timestep.

I've tried a couple things already, but haven't been able to do anything else than copy/paste it by hand, which is going to take long...


Update/Solution :

Sub test()
Worksheets("MySheet").Activate
Dim i As Double 'minutes increment
Dim j As Integer 'hourly increment
Dim k As Double
k = 0 'initialization of k
Dim Var1 As Single
Dim Var2 As Single
 For j = 1 To 8760
 Var1 = Cells(j, 8).Value 'Row "j"/from 1 to 8760, column "8"/H --> hourly values
 Var2 = Cells(j, 7).Value 'Row "j"/from 1 to 60, column "7"/G --> minutes values
 For i = 1 To 60
 
 k = k + 1 'incrementation of k to be able to insert the values in the 60 cells (corresponding to 60 minutes)
 Cells(k + 3, 10) = Var1 'insert those values in the 10th column (J) 
 Cells(k + 3, 9) = Var2 'insert those values in the 10th column (I)
 
 Next i
 Next j 
End Sub

This can also be done without VBA, as given in answer, with the function =INDEX.

Thanks for your help !

added 841 characters in body; edited title
Source Link
Loading
Source Link
Loading
lang-vb

AltStyle によって変換されたページ (->オリジナル) /