VBA date format

vbanewbie68

Board Regular
Joined
Oct 16, 2021
Messages
171
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
Hi

Can anyone help me on this please?

Please see my screenshot. How to change this: 2021-11-09T15:00:57 UTC into dd/mm/yyyyy format in VBA?

Thank you in advance

Best

V



1644610359952.png
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
If those are cells C2 to C6, the following should work in VBA:
VBA Code:
Sub ConvertCells()
    Dim Cll As Range
    For Each Cll In Range("C2:C6")
        Cll.Value = Format(Split(Cll.Value,"T")(0),"dd/mm/yyyy")
    Next
End Sub
 
Upvote 0
Solution
1644612032135.png

Hi

Thank you for this but I got an error message says Run-time error '6' Overflow. Please see screenshot above.

Best regards

V
 
Upvote 0
Noted. How do you plan on debugging and solving the problem?
 
Upvote 0
Then here is an opportunity for you to learn.

Because it works for me:
1644613214156.png
1644613248868.png
 
Upvote 0
So the question is - what is it about your setup that is causing the error? What is the name of the sheet that you have this data on?
 
Upvote 0
1644613476631.png


There is a debug as see the screenshot above so what cause this line in relation to an error: overflow?
 
Upvote 0
1644613788533.png


Got it now and it works just fine :) but on "c1" not sure why it has underscore instead of dash / ?
 
Upvote 0
1644614176030.png

I am pleased to tell you that I have done it and it works perfectly!
So many thanks for your kind help on this matter which is much appreciated! :)
Best regards

V
 
Upvote 0

Forum statistics

Threads
1,215,430
Messages
6,124,851
Members
449,194
Latest member
HellScout

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