Local settings change in pop-up label in a chart. Excel, VBA

Eddy Vlaemynck 0 Reputatiepunten
2026-09-14T15:47:46.4066667+00:00

Microsoft Office Professional Plus 2021

At first creating Page 1 in Excel:

16 consecutive dates in column A

16 values In column B (water consumption)

Make a chart on Page2:

Wt1

Values: Range("B1","B15") Name = "Water"

X-Axis: Range("A1","A15")

Wt2

As long as you stay in Excel, everything looks good. Close Excel and reopen it:Wt3

That was day 15, now we have a new day and a new value. But I don't want to change the settings every day. I created a small macro, called ... Water...

Sub Water()
Dim wmax As Double
    
    wmax = 16
    Set lbls = Sheets(1).Range("A1", "A" + CStr(wmax))
    ftxt = "=SERIES(" + Chr(34) + "Water" + Chr(34) + ",,Blad1!$B$1:$B$" + CStr(wmax) + ",1)"
    
    Sheets(2).ChartObjects(1).Chart.SeriesCollection(1).Formula = ftxt
    Sheets(2).ChartObjects(1).Chart.SeriesCollection(1).XValues = lbls
    
    'Sheets(2).ChartObjects(1).Chart.Axes(xlCategory).TickLabels.NumberFormatLocal = "dd-mm-jjjj"
End Sub

Oh wonder, it works... but.......

Wt4

That was a long story...

Is there a way to change the format of the popup in VBA? I didn't find it...

Microsoft 365 en Office | Excel | Voor thuisgebruik | Windows
0 opmerkingen Geen opmerkingen

4 antwoorden

Sorteren op: Oudste
  1. Xavier-D 13,855 Reputatiepunten Extern personeel Microsoft Moderator
    2026-09-15T03:22:41.12+00:00

    Disclaimer: Since you are using English language for this post, I will respond in the language you are using. As this is the Dutch forum, you are welcome to let me know if you need me to respond in Dutch. I respond in the language you are comfortable with. 


    Hello Eddy Vlaemynck

    Thank you for providing the screenshots and detail desciption about this issue.

    They clarify that the date labels on the horizontal axis remain correct, but after the macro updates the series, the chart’s hover tooltip displays 30-08-yy instead of the expected date.

    The following line only formats the labels displayed on the category axis:

    .Axes(xlCategory).TickLabels.NumberFormatLocal = "dd-mm-jjjj"
    ``
    

    It does not directly control the built-in tooltip that appears when the pointer is placed over a chart point. Excel VBA provides a setting to enable or disable tooltips, but Microsoft does not document a separate number-format property for the built-in chart tooltip.

    The yy shown literally suggests that the localized format code is being interpreted in a different language context. Try formatting the source date cells using the language-independent NumberFormat property and yyyy, rather than NumberFormatLocal and the Dutch jjjj code:

    Sub Water()
     Dim wmax As Long
     Dim lbls As Range
     Dim vals As Range
     Dim ser As Series
     wmax = 16
     Set lbls = Sheets(1).Range("A1:A" & wmax)
     Set vals = Sheets(1).Range("B1:B" & wmax)
     Set ser = Sheets(2).ChartObjects(1).Chart.SeriesCollection(1)
     lbls.NumberFormat = "dd-mm-yyyy"
     With ser
     .Name = "Water"
     .XValues = lbls
     .Values = vals
     End With
     With Sheets(2).ChartObjects(1).Chart
     .Axes(xlCategory).TickLabels.NumberFormat = "dd-mm-yyyy"
     .Refresh
     End With
    End Sub
    

    This also avoids constructing the SERIES formula as text. Microsoft documents that both Series.XValues and Series.Values can be assigned directly from worksheet ranges.

    Refer here for documentation about this: Series.XValues documentation and Series.Values documentation

    Please test the macro on a copy of the workbook. If the tooltip still shows yy literally while the source cells and axis labels remain correct, that will indicate a limitation or unexpected behavior in Excel’s built-in chart tooltip rather than the category-axis formatting.

    In that case, a fully controlled tooltip would require a custom VBA solution, such as displaying formatted text in a text box when a chart point is selected.

    I hope this helps.

    Feel free reply back to this post if you need further assistance, I'll be happy to help.

    Was dit antwoord nuttig?

    0 opmerkingen Geen opmerkingen

  2. Verwijderd

    Dit antwoord is verwijderd vanwege een schending van onze gedragscode. Het antwoord is handmatig gerapporteerd of geïdentificeerd via geautomatiseerde detectie voordat er actie werd ondernomen. Raadpleeg onze Gedragscode voor meer informatie.


    Opmerkingen zijn uitgeschakeld. Meer informatie

  3. Verwijderd

    Dit antwoord is verwijderd vanwege een schending van onze gedragscode. Het antwoord is handmatig gerapporteerd of geïdentificeerd via geautomatiseerde detectie voordat er actie werd ondernomen. Raadpleeg onze Gedragscode voor meer informatie.


    Opmerkingen zijn uitgeschakeld. Meer informatie

  4. Eddy Vlaemynck 0 Reputatiepunten
    2026-09-15T13:15:21.35+00:00

    Het kan inderdaad in het Nederlands. Maar de help verwijst naar de US-Site. Ik dus alles maar in het Engels doorgegeven...

    Uiteindelijk nemen ze niks aan en kan ik niks plaatsen... Dan maar een andere weg gezocht (deze weg) maar niet de moeite genomen om alles terug in het Nederlands te zetten... Ondertussen zelf een oplossing gevonden...

    Als ik de code uitvoer zoals U me hebt gegeven:

    Sub Water()
     Dim wmax As Long
     Dim lbls As Range
     Dim vals As Range
     Dim ser As Series
     wmax = 16
     Set lbls = Sheets(1).Range("A1:A" & wmax)
     Set vals = Sheets(1).Range("B1:B" & wmax)
     Set ser = Sheets(2).ChartObjects(1).Chart.SeriesCollection(1)
     lbls.NumberFormat = "dd-mm-yyyy"
     With ser
     .Name = "Water"
     .XValues = lbls
     .Values = vals
     End With
     With Sheets(2).ChartObjects(1).Chart
     .Axes(xlCategory).TickLabels.NumberFormat = "dd-mm-yyyy"
     .Refresh
     End With
    End Sub
    
    

    Krijg ik dit:

    Wt5 Dat is eigenlijk niet beter. Maar ik heb wel opgemerkt dat als je kolom A terug een "format" geeft dat 30-08-yyyy terug 30-8-2026 geeft, en bij kolom B hetzelfde, waarde komt terug goed... en ik heb dit nu vanuit het programma gedaan...

    Sub Water()
     Dim wmax As Long
     Dim lbls As Range
     Dim vals As Range
     Dim ser As Series
     
     wmax = 16
     Set lbls = Sheets(1).Range("A1:A" & wmax)
     Set vals = Sheets(1).Range("B1:B" & wmax)
     Set ser = Sheets(2).ChartObjects(1).Chart.SeriesCollection(1)
     lbls.NumberFormat = "dd-mm-yyyy"
     
     With ser
        .Name = "Water"
        .XValues = lbls
        .Values = vals
     End With
     
     With Sheets(2).ChartObjects(1).Chart
        .Axes(xlCategory).TickLabels.NumberFormat = "dd-mm-yyyy"
        .Refresh
     End With
    
     Sheets(1).Columns("A").NumberFormat = "dd-mm-yyyy"
     Sheets(1).Columns("B").NumberFormat = "0.000"
    End Sub
    
    

    En dan krijg ik dit:

    Wt6

    Dat is OK voor mij... (nu programma voor digitale meter bijwerken...)

    Was dit antwoord nuttig?


Uw antwoord

Antwoorden kunnen worden gemarkeerd als 'Geaccepteerd' door de auteur van de vraag en 'Aanbevolen' door moderators, zodat gebruikers het antwoord van de auteur kunnen weten.