+ Reply to Thread
Results 1 to 11 of 11

Format Major Gridlines with VBA in Excel 2010

  1. #1
    Registered User
    Join Date
    02-10-2013
    Location
    UK
    MS-Off Ver
    Office 365, Version 2208
    Posts
    24

    Format Major Gridlines with VBA in Excel 2010

    I would like to use Excel VBA to format the line color of major gridlines in various charts please. Unfortunately recording a macro while performing the actions results in the following:

    Please Login or Register  to view this content.
    I basically want to create a Gradient Line, and to do this manually I follow these steps:
    1. Select the gridlines on my chart
    2. Right-click and choose Format Gridlines...
    3. Within Line Color, select Gradient line
    4. Stop 1 of 3:
      -Grey -50%
      -Brightness -25%
      -Transparancy 100%
    5. Stop 2 of 3:
      -Grey -25%
      -Brightness -15%
      -Transparancy 0%
    6. Stop 3 of 3:
      -White
      -Brightness -0%
      -Transparancy 100%
    7. Angle 0

    Can this be done programatically? Any help very much appreciated.

  2. #2
    Registered User
    Join Date
    09-27-2011
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    86

    Re: Format Major Gridlines with VBA in Excel 2010

    Hi,

    In the above code - take out the last 2 lines and use the with loop.

    Please Login or Register  to view this content.
    Now - update the colors of your choice.

    Regards,
    lokicl

  3. #3
    Registered User
    Join Date
    02-10-2013
    Location
    UK
    MS-Off Ver
    Office 365, Version 2208
    Posts
    24

    Re: Format Major Gridlines with VBA in Excel 2010

    Thank you for your help Lokicl - does this code apply a gradient colour as it seems to only apply a solid colour?

    As per my example, I need to set a specific colour, brightness, and transparency for each element in the gradient line.

    Thanks.

  4. #4
    Registered User
    Join Date
    09-27-2011
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    86

    Re: Format Major Gridlines with VBA in Excel 2010

    Hi,

    You have update the color index number and RGB color (0,255,0) for different colors and combinations.

    Regards,
    lokicl

  5. #5
    Registered User
    Join Date
    11-24-2014
    Location
    egypt
    MS-Off Ver
    2013
    Posts
    2

    Re: Format Major Gridlines with VBA in Excel 2010

    Hi,
    Sorry for breaking the rules but
    I had a big problem can't wait to help me solve it
    Iam working in steel fabrication and sheets company that use large amount of sizes in the same item , like steel sheet width 1.25 meter length 5 meter cut it into Defferent sizes i want excel to change the original item to the sizes i got after cutting and give me the summary inventory .
    Thanks,
    Hisham shamy

  6. #6
    Registered User
    Join Date
    02-10-2013
    Location
    UK
    MS-Off Ver
    Office 365, Version 2208
    Posts
    24

    Re: Format Major Gridlines with VBA in Excel 2010

    Quote Originally Posted by lokicl View Post
    Hi,

    You have update the color index number and RGB color (0,255,0) for different colors and combinations.

    Regards,
    lokicl
    Oh I see - thanks I'll give that a go!

    Ignore that other post from hishamshamy, completely unrelated to my question....

  7. #7
    Registered User
    Join Date
    11-24-2014
    Location
    egypt
    MS-Off Ver
    2013
    Posts
    2

    Re: Format Major Gridlines with VBA in Excel 2010

    Hi
    If you don't mind where can i get my answer ?
    Thanks

  8. #8
    Registered User
    Join Date
    02-10-2013
    Location
    UK
    MS-Off Ver
    Office 365, Version 2208
    Posts
    24

    Re: Format Major Gridlines with VBA in Excel 2010

    Start a new thread.

  9. #9
    Registered User
    Join Date
    02-10-2013
    Location
    UK
    MS-Off Ver
    Office 365, Version 2208
    Posts
    24

    Re: Format Major Gridlines with VBA in Excel 2010

    Thank you for your help, but it's not working the way I was hoping.

    When I run through the loop, all it does is change the major gridlines to the specified colour - blue first, then green, then orange, with no gradient being applied.

    Hopefully these screenshots help explain what I'm trying to do:

    majorGridlines.png
    majorGridlines2.png

    (except that image uploader doesn't appear to work)

  10. #10
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,441

    Re: Format Major Gridlines with VBA in Excel 2010

    I don't think this is supported in the object model.

    Line format does not have the GradientStops properties that the FillFormat does.
    Cheers
    Andy
    www.andypope.info

  11. #11
    Registered User
    Join Date
    02-10-2013
    Location
    UK
    MS-Off Ver
    Office 365, Version 2208
    Posts
    24

    Re: Format Major Gridlines with VBA in Excel 2010

    ahh I see - shame.

    Thanks for your help!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Major gridlines for each month on horizontal axis
    By hstaubyn in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 10-30-2013, 06:17 AM
  2. Vertical Minor Gridlines Overlap Horizontal Major Gridlines
    By dsalzman in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 03-13-2012, 11:49 AM
  3. Excel 2010 Gridlines
    By TimEd in forum Excel General
    Replies: 7
    Last Post: 03-06-2012, 01:43 PM
  4. minor and major gridlines
    By rafi in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 12-01-2005, 11:15 AM
  5. Value Axis Major Gridlines
    By rasta1979 in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 10-14-2005, 10:05 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1