VBA Loop

Juanseefour

New Member
Joined
Sep 24, 2017
Messages
8
Hi Folks,

So need a bit of help. I have hh/raw electricity data that goes horizontaly and i need a vba loop to transpose it vertically. If that makes sense.

EG. raw data

Day-00:30 next column 01:00 etc

I need it to go vertically (not being lazy) but this is over 5,000 odd rows.

Any help would be greatly appreciated please.
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Got there in the end, here is an example if anyone has the pleasure of working with lots of HH electricity data. Thanks for trying to help. Was under bit of pressure so had to batter through!

Sub NewMacro()

Dim count As Integer
Dim valueofOffset As Integer
count = 3
valueofOffset = 1
Worksheets.Add().Name = "WorkingSheet"
Worksheets("WorkingSheet").Range("B2").Value = "DATETIME"
Worksheets("WorkingSheet").Range("C2").Value = "HH Reading"

Dim dateRange As Range
Set dateRange = Worksheets("Meter Reading Table").Range("B2:B800")
Dim hourRange As Range
Set hourRange = Worksheets("Meter Reading Table").Range("C1:AX1")
For Each d In dateRange.Cells

For Each h In hourRange.Cells

Worksheets("WorkingSheet").Cells(count, "B").Value = d.Value + "_" + h.Value
Worksheets("WorkingSheet").Cells(count, "C").Value = h.offset(valueofOffset, 0)

count = count + 1

Next h

valueofOffset = valueofOffset + 1

Next d
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top