+ Reply to Thread
Results 1 to 6 of 6

VBA to set shape outline color from variable

  1. #1
    Registered User
    Join Date
    03-02-2006
    Location
    USA
    MS-Off Ver
    O365 PC, Version 2207, 64bit
    Posts
    63

    Arrow VBA to set shape outline color from variable

    I have a shape created and am looking to set the color based on a RGB value stored in variable.

    Data in H2: RGB(0,255,255)

    HTML Code: 
    I'm getting a Run-time error '13': Type Mismatch.

    The debug.print shows "RGB(0, 255, 255)" (without quotes).

    If i replace the variable MyColor and manually type in RGB(0, 255, 255) it works just fine.

    I also tried to Dim my variable as long, but that also failed, at copying the value in H2.
    Last edited by Remotruker; 05-08-2020 at 10:41 AM.

  2. #2
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,151

    Re: VBA to set shape outline color from variable

    See:
    https://www.excelforum.com/excel-pro...bal-const.html

  3. #3
    Registered User
    Join Date
    03-02-2006
    Location
    USA
    MS-Off Ver
    O365 PC, Version 2207, 64bit
    Posts
    63

    Re: VBA to set shape outline color from variable

    Thanks. I must be missing the relevance. I am trying to take a value from a cell and store it into a variable. Whereas the referenced post is providing the values directly within VBA code.

    If i provide the values directly i the vba code(eliminating the variable), it works fine.

    Quote Originally Posted by porucha vevrku View Post
    Last edited by Remotruker; 05-08-2020 at 10:24 AM.

  4. #4
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,151

    Re: VBA to set shape outline color from variable

    You have read this topic not very carefully - look below:
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    03-02-2006
    Location
    USA
    MS-Off Ver
    O365 PC, Version 2207, 64bit
    Posts
    63

    Re: VBA to set shape outline color from variable

    You are still defining the values within the VBA Code.

    Please Login or Register  to view this content.
    and
    Please Login or Register  to view this content.
    I have resolved my issue by defining 3 variables

    Please Login or Register  to view this content.
    and calling them in the ForeColor:

    Please Login or Register  to view this content.

  6. #6
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,151

    Re: VBA to set shape outline color from variable

    You still read "this" not very carefully - these 'RGB' values ​​in the code are only for color reset for shapes for visual testing, so that you can easily see what happens during code execution. The correct values ​​are taken from the worksheet.

+ 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. Change Shape Color RGB based on Cells Color
    By jocker_boy in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-30-2019, 05:31 AM
  2. Using Worksheet_change to change shape outline color
    By neima in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-27-2017, 11:41 AM
  3. Replies: 1
    Last Post: 07-21-2016, 09:29 AM
  4. Get shape name as a cell value if shape has an outline of a certain colour
    By kamazonka in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-05-2016, 11:57 AM
  5. How to apply "Shape Outline" on the Bar charts with Excel VBA
    By trizzo in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-19-2015, 08:19 AM
  6. Add command button to shape and change shape color on mouseover
    By maacmaac in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-26-2012, 05:12 PM
  7. [SOLVED] VBA To Change Shape Outline
    By cmstroh in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-12-2012, 06:36 AM

Tags for this Thread

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