+ Reply to Thread
Results 1 to 5 of 5

Concatenate msoThemeColorAccent with the Value of j in For Next Loop

  1. #1
    Registered User
    Join Date
    05-18-2022
    Location
    Ljubljana
    MS-Off Ver
    2016
    Posts
    16

    Concatenate msoThemeColorAccent with the Value of j in For Next Loop

    I am going to use a For Next loop to change the color of lines for five different series. The colors I'm using are:

    msoThemeColorAccent1
    msoThemeColorAccent2
    msoThemeColorAccent3
    msoThemeColorAccent4
    msoThemeColorAccent5

    The segment of the code with the loop is:


    Dim j As Integer

    For j=1 to 5

    ActiveChart.FullSeriesCollection(j).Format.Line.ForeColor.ObjectThemeColor = #msoThemeColorAccent concatenated with j#

    Next j


    It seems my problem is very trivial, yet I cannot get the concatenation right, i.e. msoThemeColorAccent & j.

    I am kindly asking for some advice.

    Regards,
    Robert

  2. #2
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,907

    Re: Concatenate msoThemeColorAccent with the Value of j in For Next Loop

    You can't refer to an Enum value using text like that. However, it happens that those values are in ascending order starting at 5, so you can use:
    Please Login or Register  to view this content.
    Rory

  3. #3
    Registered User
    Join Date
    05-18-2022
    Location
    Ljubljana
    MS-Off Ver
    2016
    Posts
    16

    Re: Concatenate msoThemeColorAccent with the Value of j in For Next Loop

    Hi Rory, thank you for your reply.

    Well the colours I'm using are from a custom-made palette and they are called exactly "msoThemeColor1" etc (I've got this name from recording the macro first).

    If I understand your reply correctly, these names can be simply replaced by an integer? I'm asking because I'm quite new to the VBA code and would like to learn about it.

    Regards,
    Robert

  4. #4
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,907

    Re: Concatenate msoThemeColorAccent with the Value of j in For Next Loop

    Yes, Enums are actually just names given to numeric values. msoThemeColorAccent1 is 5 and so on.

  5. #5
    Registered User
    Join Date
    05-18-2022
    Location
    Ljubljana
    MS-Off Ver
    2016
    Posts
    16

    Re: Concatenate msoThemeColorAccent with the Value of j in For Next Loop

    Got it, thank you!

+ 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. [SOLVED] need help using a for loop to concatenate cells
    By learner99 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-15-2014, 10:35 AM
  2. How to get Concatenate to loop
    By kinglue in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-13-2012, 12:40 PM
  3. Loop/Concatenate/SaveAs text ?
    By d_cww in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 10-19-2011, 02:54 AM
  4. Filter then Concatenate Loop
    By tmkennedy1 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-06-2011, 09:01 PM
  5. Concatenate paste loop
    By mcinnes01 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-28-2011, 12:46 PM
  6. Concatenate Loop
    By FIRSTROUNDKO via OfficeKB.com in forum Excel General
    Replies: 4
    Last Post: 03-11-2006, 08:40 AM
  7. Replies: 3
    Last Post: 03-29-2005, 04:06 PM

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