Creating a Macro to edit cells

ABCMIKE

New Member
Joined
Jun 9, 2015
Messages
3
Hello, I'm having a nightmare...

I have a sheet with over 1000 times in cells. They are writes as HH:MM:SS:SS. I need them in HH:MM:SS format. I'm unable to change it in the Format Cells option. I was told a macro could do this, but when I've tried, it's just replacing the time in the cell with the time I recorded in the Macro. I'm losing information trying to get it right.

Can anyone help please?

Mike
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
If you are unable to make the change via Format Cells by using Custom > h:mm:ss....

You could try something like this:


Code:
Sub test()
'
Range("A1:AZ106").NumberFormat = "h:mm:ss" 'you just need to select your cells via some selection
'or by columns
Columns("3:10").NumberFormat = "h:mm:ss"
'or by rows
Rows("2:40").NumberFormat = "h:mm:ss"
'
End Sub

You just have to figure out how you are going to select the cells you need to change.

However, if the custom number formatting doesn't work with "Format Cells", then I am not sure this will work either.

TEST on a BACKUP COPY
 
Upvote 0
Thanks I'll give it a go. I hope it does work, but I'm not sure it will as it won't work with format cells pre macro.

As with excel, something sounds simple, but seldom is.

Thanks again :)
 
Upvote 0
If that doesn't work, you may need to upload a sample of the worksheet so we can try to understand why Format cells isn't working for it.
 
Upvote 0
Oh ok, I didn't know I could do that. It's a really simple worksheet. There's not sensitive information on there, it's literally figures relating to figures. I will try your suggestion and if that doesn't work, maybe you could tell me where I upload my/a sheet?

Thanks :)
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

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