www.EXCELITEMS.com

April 23, 2009

Color only a part of cell using Macro or REPT Function

Filed under: Queries and Solutions, VBA Macro — ashishjain @ 7:00 pm

Query Source    : Excel Macros Google Group
Solution Type   : VBA Macro
Query by               : ExcelUser777
Solution by         : Ashish Jain (MCAS; MCA; Lead Trainer, Success Electrons)


Query / Problem:
HI
Basically i’d like to only show coloring in part of a cell, so for example
Cell A1 is grey only 33% of the cell is grey -I’d like to color one cell grey 33%. I have several cells to color, different percentages. Once I see one macro I can create the other percentages. Is that possible with a macro?
Appreciate all your help.
Excel 2003 preferably
Thanks,
ExcelUser777


Solution:
1. Using Macro

i)   Select the range (It should be in terms of percentage, else change the following code accordingly.)
ii)  Press Alt+F11.
iii) Paste the following code in Code window.
iv) Run the macro and enjoy.

View VBA Macro Code here.

2. Using REPT Function

i) Use REPT function to repeat the pipe symbol, | as displayed in formula box Below.



Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment

Blog at WordPress.com.