xlCategoryScale does not work for Date and Time axis

Angie86

New Member
Joined
Feb 3, 2021
Messages
2
Office Version
  1. 2019
Platform
  1. Windows
Hello Everyone!

I am writing a code to organise some charts. In the x-axis I have date and time in the format "DD.MM.YYYY hh:mm:ss", and because all the measurements change with time, I need the x-axis to the format on Column B (Figure on the left). Initially, the axis ticks are numbers (Figure in the middle), and to change them to the format I want, I have used so far the following line, that based on some other questions, may work:

With Plot_Pressure
.Axes(xlCategory, xlPrimary).CategoryType = xlCategoryScale
End With

However, after running that the axis tick does not change and if I include the line ".Axes(xlCategory).TickLabels.NumberFormat = "dd.mm.yyyy hh:mm:ss"" after, the result is even worst (Figure on the right).

Could someone please help me with it?
I would really appreciate it!
Thanks!!!

1612348757187.png
1612348700715.png
1612349108440.png
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
What result are you expecting? Your number format is quite long, so that's why you get the result in the third image.
 
Upvote 0
I am expecting to see at least the time interval in which the data should be.
Although my number format is too long, as you can see in the image the axis does not match, considering that my data goes from "01.09.2020 00:00:09" until "30.09.2020 23:59:59"
 
Upvote 0
As it looks like your data is at regular 10 second intervals, you could simply use a category axis. Alternatively, use an XY scatter chart with lines, and then alter the number format of the X axis to use a date format. It is unfortunately often very difficult to work out the problem with a chart from a picture rather than an actual workbook.
 
Upvote 0

Forum statistics

Threads
1,214,943
Messages
6,122,380
Members
449,080
Latest member
Armadillos

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