Macro question

cajste

Board Regular
Joined
Oct 22, 2012
Messages
67
I have a big range of data where where some of the cells have the wrong format when I get the it and calculations will not work because of that. If I selcet a cell, pushes F2 and then Enter the format will be corrected. However there are 20 000 rows and this needs to be done for 4 cells on each row so it is not doable.

What would a macro that selects a cell, pushes F2 and Enter, selects the next cell on the row, does the same thing and loops through all rows look like?

The first row shows the data as it looks when I get it and the second the way it should look.

Col1Col2Col3Col4Col6Col7
0:11:520:12:09TRUE0:03:5704 jan 2016 9:46:540:17:20
00:11:5200:12:09TRUE00:03:572016-01-04 09:4600:17:20

<tbody>
</tbody>

//Caj
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
See if this does it. Test on a copy.

Rich (BB code):
Sub FixIt()
  With ActiveSheet.UsedRange
    Union(.Columns("A:B"), .Columns("D"), .Columns("F")).NumberFormat = "hh:mm:ss"
    .Columns("E").NumberFormat = "yyyy-mm-dd hh:mm"
    .Value = .Value
  End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,586
Messages
6,120,402
Members
448,958
Latest member
Hat4Life

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