Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7798113
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T23:54:15+00:00 2026-06-01T23:54:15+00:00

I need to round off the X-ticklabels in an excel chart to the nearest

  • 0

I need to round off the X-ticklabels in an excel chart to the nearest 50. The charts are created in VBA, the data series is in a worksheet so I would be happy to use a solution in either. I have written the following function that rounds to the nearest 50:

  Function RoundTo50(number As Double) As Double
      RoundTo50 = WorksheetFunction.Round(number * 2, -2) / 2
  End Function

I have applied it to the min and max x limits of the chart and it works for them, but I can’t work out how to apply this to all the ticklabels in between. I thought of applying it to all the data before plotting but that would alter the plot which I don’t want to do. I would prefer for the ticklabels to be slightly misaligned due the rounding.

Can you do this with a formatting string? Or any other way?

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T23:54:17+00:00Added an answer on June 1, 2026 at 11:54 pm

    So the answer is as follows (thanks to Sam Ward for the comment that pushed me in the right direction):

    Use my RoundTo50() function to round of the min and max limits to the nearest 50. Calculate what the interval should be for a reasonable amount of grid lines, in my case 12. Round this interval to the nearest 50.

    Function RoundTo50(number As Double) As Double
        RoundTo50 = WorksheetFunction.Round(number * 2, -2) / 2
    End Function
    

    and

    With Sheets("Report").ChartObjects.Add(...)
        .Chart.Axes(xlCategory).MinimumScale = RoundTo50(Sheets(sheetName).Range("M4"))
        .Chart.Axes(xlCategory).MaximumScale = RoundTo50(Sheets(sheetName).Range("M124"))
        .Chart.Axes(xlCategory).MajorUnit = RoundTo50((.Chart.Axes(xlCategory).MaximumScale - .Chart.Axes(xlCategory).MinimumScale) / 12)
        .Chart.Axes(xlCategory).MinorUnit = .Chart.Axes(xlCategory).MajorUnit / 3
    

    I would still be very much interested in being able to do this with a formatting string though as I have a secondary axis in percent and the grid lines from rounding to 50 are slightly offset with the tick marks of the secondary axis. With a formatting string they would be perfectly aligned (because they would be slightly in the wrong place but I would prefer that).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to round-off the hours based on the minutes in a DateTime variable.
I need to round floating point numbers up to the nearest integer, even if
I need to round times down to the nearest quarter hour in PHP. The
In my iPhone app I need to round an integer to the nearest multiple
I need a formula in excel to round my price list. Last digit of
I need to round up to the nearest 0.10 with a minimum of 2.80
I need to round up to the nearest tenth. What I need is ceil
I need to round money values up to the nearest cent, then do some
I need to round a value up to the nearest multiple of 2.5. For
I have a BigDecimal calculation result which I need to round to the nearest

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.