Jump to content


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.

Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.


VBA - a question

  • Please log in to reply
1 reply to this topic

#1 espinet


  • Members
  • 11 posts
  • Location:Bristol, UK
  • Local time:07:26 AM

Posted 23 May 2005 - 04:28 PM

Hi everyone,

I hope someone can help me doing this: I would like to take a drawing (for example some polygonal shape) with grid inside (not necessarily square elements), and after that I would like to colour in each different cell individually. Can anybody tell me whether it is possible to colour in each cell according to an Excel table using VBA?? :thumbsup:

Sorry I know it is not very clear, but if you need me to further clarify I'll be happy to do it.

Thanks in advance,


BC AdBot (Login to Remove)


#2 tos226



  • Members
  • 1,577 posts
  • Gender:Female
  • Location:LocalHost
  • Local time:08:26 AM

Posted 26 May 2005 - 10:02 PM

Not completely clear to me :thumbsup:
But I'll take a guess and possibly provide few hints how to go about it.

I presume your polygon will be in front of excel grid and you want to color the grid and you have a lookup table in excel to select the color based on some business rule in your polygon.

Let's say you already have the color value looked up. On to the color syntax:

If a cell is selected, the syntax would be
Selection.Interior.ColorIndex = someNumber 0,255,37

If not selected, you could address, in a loop or individually, each cell you want to colour, generally using a syntax such as

You can try recording a macro for the entire process, pickup the syntax from there, then modify it for some flexibility, i.e. not fixed cell addresses.

Recording is the best way, anyway, especially that in the UK it just might read ColourIndex :flowers:
Once you record, F1 over VBA keywords takes you to help which explains what you recorded in great detail and then you can make Excel sing.

Edited after rereading your post, and guessing some more:
You might be asking about coloring the polygon itself, i.e. my guesses are incorrect. If so, I can't give you an answer quickly, because it will involve addressing drawing objects in VBA rather than Excel ranges. Someone else would need to jump in if that's the case.

Edited by tos226, 26 May 2005 - 10:05 PM.

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users