Excel VBA - Change color of a shape

แชร์
ฝัง
  • เผยแพร่เมื่อ 31 ต.ค. 2024

ความคิดเห็น • 48

  • @modalgvr
    @modalgvr 3 ปีที่แล้ว

    Thanks very much. your video helped me a lot!

    • @ahsingtv
      @ahsingtv  3 ปีที่แล้ว

      My pleasure. Thanks for watching and have a nice day.

  • @PLara-tf4eg
    @PLara-tf4eg 3 ปีที่แล้ว

    AMAZING!!! please continue

    • @ahsingtv
      @ahsingtv  3 ปีที่แล้ว

      Thanks!
      Thanks for watching and have a nice day.

  • @hageraamer749
    @hageraamer749 2 ปีที่แล้ว

    Well done 🌺😊

    • @ahsingtv
      @ahsingtv  2 ปีที่แล้ว +1

      Thanks!
      Thanks for watching and have a nice day.

  • @NA-nv3mn
    @NA-nv3mn 2 ปีที่แล้ว

    Hi Sing, thanks for the video.
    One question, can we draw the data from the table horizontally instead of vertically? (@01:45)

    • @ahsingtv
      @ahsingtv  2 ปีที่แล้ว

      Hi friend, the answer is yes.
      Instead of having the column fixed, we could fix the row.
      For example, use a = Sheet13.Cells(2, i + 1) / 501 * 255 instead of a = Sheet13.Cells(i + 1, 2) / 501 * 255
      Hope this helps. Thanks for watching and have a nice day. 😀

    • @NA-nv3mn
      @NA-nv3mn 2 ปีที่แล้ว

      Thanks for your prompt reply, it works well.

    • @ahsingtv
      @ahsingtv  2 ปีที่แล้ว

      My pleasure 😊

  • @mukeshindian1028
    @mukeshindian1028 4 ปีที่แล้ว

    Nice info, thanks

    • @ahsingtv
      @ahsingtv  4 ปีที่แล้ว

      My pleasure.
      Thanks for watching and have a nice day.

  • @arsyidaldipratama4458
    @arsyidaldipratama4458 2 ปีที่แล้ว

    thanks for vidoe, so helpfully.
    please help me, if one of another case value want to become transparency or no fill colour, whats the code please?? 😢😢

    • @ahsingtv
      @ahsingtv  2 ปีที่แล้ว

      Hi.
      For no fill 👉 Sheet1.Shapes.Range(Array("FreeForm 1")).Fill.Visible = msoFalse
      For transparent 👉 Sheet1.Shapes.Range(Array("FreeForm 1")).Fill.Transparency = *value 0 to 1*
      Hope it helps.
      Thanks for watching and have a nice day.

    • @arsyidaldipratama4458
      @arsyidaldipratama4458 2 ปีที่แล้ว

      @@ahsingtv i send you email for my problem, if you have time, plase send me back

  • @okvr90
    @okvr90 3 ปีที่แล้ว

    Thanks for this Video. I got the steps it worked But I want to know how you made it refresh without using the button.

    • @ahsingtv
      @ahsingtv  3 ปีที่แล้ว

      Hi. My pleasure.
      Regarding your question, set "Worksheet" as Object and "Change" as procedure. May refer to 7:55".
      Thanks for watching and have a nice day.

  • @albertgunawan8017
    @albertgunawan8017 3 ปีที่แล้ว

    Is pattern fill possible? I want to use .Patterned msoPatternWideUpwardDiagonal but no clue. Can you help?

    • @ahsingtv
      @ahsingtv  3 ปีที่แล้ว

      Hi. I'm so sorry that I have overlooked your message.
      Yes, is possible.
      Here's a video for your reference th-cam.com/video/uu7fWpSk9C0/w-d-xo.html
      Thanks for watching and have a nice day.

  • @franciscomerizalde7423
    @franciscomerizalde7423 4 ปีที่แล้ว

    Hello Ah Sing, I phasing an issue when I try to apply this sort of code to a warehouse map, with about 692 locations. I manage to create all little rectangles and named all of them, place the code in place and for some reason, it only works for (For i = 1 to 15) when I try to increase the range to (For i = 1 to 692) it tell me that some range it's out of boundaries. Would you please help me ?

    • @ahsingtv
      @ahsingtv  4 ปีที่แล้ว

      Hi Francisco. Sorry for this late. Have done it for you. Kindly check your email.
      Thanks for watching and have a nice day.

  • @ankitmallick843
    @ankitmallick843 4 ปีที่แล้ว

    Hi! Awesome video. I'm facing some issues when i'm trying this, could you please help me out? Thanks in advance.

    • @ahsingtv
      @ahsingtv  4 ปีที่แล้ว +1

      May I know what kind of issues are you referring?
      Thanks for watching and have a nice day.

  • @yasseryousry4185
    @yasseryousry4185 ปีที่แล้ว

    THAT IS GOOD BUT HOW CAN YOU LINK THIS SHAP BY THE CELLS

    • @ahsingtv
      @ahsingtv  ปีที่แล้ว

      Hi. In this video, these shapes are linked to cells using a dummy variable 'i.' To be honest, this isn't the best approach because we must ensure that the sequence of the shapes exactly matches the order of the cells. A better method is to rename the shapes. Thanks for watching and have a nice day.

    • @yasseryousry4185
      @yasseryousry4185 ปีที่แล้ว

      EXCUSE ME BUT CAN YOU EXPLAIN IN DETAILS HOW CAN I LINK A CELL TO IRREGULAR SHAPE@@ahsingtv

    • @ahsingtv
      @ahsingtv  ปีที่แล้ว

      Hi. I have a video for you at th-cam.com/video/FZGp1v4LERU/w-d-xo.html. Hope it helps.
      Have a nice day.

  • @ratbcbnaatsite2429
    @ratbcbnaatsite2429 2 ปีที่แล้ว

    Nice Video, I have facing a problem . How to set Shape with it's name ? I have 23 shapes in a map. when I put the value or change the value , the color dose not changed for right shape. Please Help

    • @ahsingtv
      @ahsingtv  2 ปีที่แล้ว

      Thanks! 🤔 It's difficult to express in words but I have a video on that issue at th-cam.com/video/UQSZ040f5dM/w-d-xo.html, kindly seek to time 1:39.
      Similar work could also be found in the videos th-cam.com/video/uu7fWpSk9C0/w-d-xo.html and th-cam.com/video/ct9rxDNw9kk/w-d-xo.html within the first minute.
      Hope they help.
      Thanks for watching and have a nice day.

    • @dpsjalpaiguri9034
      @dpsjalpaiguri9034 2 ปีที่แล้ว

      @@ahsingtv runtime error 1004: " The item with the specified name wasn't found"

    • @dpsjalpaiguri9034
      @dpsjalpaiguri9034 2 ปีที่แล้ว

      PLEASE SEND YOUR MAIL ADDRESS TO dpswbjpg@rntcp.org . then I will send you the file for check.

    • @ahsingtv
      @ahsingtv  2 ปีที่แล้ว

      @@dpsjalpaiguri9034 Hi. This is because the names of shapes and the references used in VB are not matched.
      Suggestion, either rename the shapes in accordance with the VB references or vice versa.
      Hope it helps. Have a nice day 😊

    • @anujal1
      @anujal1 2 ปีที่แล้ว

      If you send your mail ID then I will send you the file for repair from your end

  • @adaobianyachor2681
    @adaobianyachor2681 2 ปีที่แล้ว

    Hello. Ah Sing. Thank you for your video. I need to create a percent color fill for 37 shapes, where =80% should be red. The values on the data are in percentages and they spool from PIVOT table currently located on another sheet from column 17 row 2.
    Based on your tutorial, this is my code
    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    For i = 1 To 38
    a = Sheet6.Cells(i + 1, 17) / 100 * 255
    b = 20 / Sheet6.Cells(i + 1, 17) * 255
    Sheet6.Shapes.Range(Array("Freeform " & i + 1)).Fill.ForeColor.RGB = RGB(a, b, 0)
    Next i
    End Sub
    However, I have an runtime error 6 'Overflow' and the error keeps pointing to
    Sheet6.Shapes.Range(Array("Freeform " & i + 1)).Fill.ForeColor.RGB = RGB(a, b, 0)
    Kindly assist.
    Best

    • @ahsingtv
      @ahsingtv  2 ปีที่แล้ว

      Hello Adaobi. May I know, are the names of shapes labelled in sequence (2 to 39), eg. FreeForm 2, FreeForm 3, and so on? As according to your code, you should have FreeForm 2 to FreeForm 39 since you are using "Array("Freeform " & i + 1)".
      Thanks for watching and have a nice day.
      To change the name of a shape 👉 th-cam.com/video/fn1wYvvqpUk/w-d-xo.html

  • @jesaresta571
    @jesaresta571 4 ปีที่แล้ว

    Hi there could you please help me out of something similar vba? Thanks

    • @ahsingtv
      @ahsingtv  4 ปีที่แล้ว

      Hi Jes. Have settled for you.
      Thanks for watching and have a nice day.

  • @naveedsaeedpcro9943
    @naveedsaeedpcro9943 5 ปีที่แล้ว

    Can you please
    help me getting it change for my shapes ?

    • @ahsingtv
      @ahsingtv  5 ปีที่แล้ว

      No problem. I will try my best. Do send me your spreadsheet to my email at durian1.apple@gmail.com, do indicate the condition for the change.
      Please notify me after sent. Thanks ya.

    • @naveedsaeedpcro9943
      @naveedsaeedpcro9943 5 ปีที่แล้ว

      Dears
      Please check your email.
      I have send an email.

    • @ahsingtv
      @ahsingtv  5 ปีที่แล้ว

      Hi there, have done it for you.
      Hope it helps. Have a nice day.

  • @JuanCarlosQuispeQuispe
    @JuanCarlosQuispeQuispe 4 ปีที่แล้ว +2

    Gracias por el código, y por si a alguien le sirve les comparto un archivo de prueba drive.google.com/file/d/1ManKe7aDLmLkIlKYtQp_KRkcdWL1azWm/view?usp=sharing

    • @ahsingtv
      @ahsingtv  2 ปีที่แล้ว

      👏👏

    • @omarperezr
      @omarperezr 2 ปีที่แล้ว

      Me pierdo en la parte donde vincula cada sección del mapa con el código o con los datos. ¿Es por orden de creación?

  • @hilmansuryadi4171
    @hilmansuryadi4171 ปีที่แล้ว

    Hi ah sing, thanks for the video.
    i have send an email.
    please check your email. thank you

    • @ahsingtv
      @ahsingtv  ปีที่แล้ว

      Hi Hilman. I couldn't find the file, I guess I had deleted it since it was about five years ago. Sorry for that.
      Thanks for watching and have a nice day.