Use REPT() to draw in-cell bar charts / sparklines

Use REPT() to draw in-cell bar charts / sparklines

The REPT() function is used to repeat a text, 'n' number of times. This can be used in interesting ways. For example, you can use this function to draw a bar chart within a cell.

Here is a sample spreadsheet which uses the REPT() function for in-cell charts. 



This spreadsheet holds the statistics of previous Wimbledon championship winners by Country. The range B3:B16 is named 'gentscount' and the range F3:F13 is named 'ladiescount'. Cell D2 is named 'maxbars' and it refers to the maximum width of the bar chart. You can view the various named ranges on the spreadsheet by clicking on the Name Box, which is available at the top towards the left of the Formula Bar.

Now let us look at the formula used in cell C3:

=REPT("|";B3/MAX(gentscount)*maxbars)

The first argument to the REPT() function denotes the text to be repeated. We use the pipe symbol or the vertical bar,  | , in this case to achieve a bar graph feel. 

The second argument denotes the number of times the text should be repeated. In this case, we divide each country's count [  B3   ] with the maximum value in the range 'gentscount' [  MAX(gentscount)   ] to denote each country's count on a scale of 0 to 1. We then multiply it by the maximum number of bars [ maxbars ] configured in the spreadsheet. So in any event, the maximum width of the bar will be in control as per the value in cell 'maxbars'.

Finally, we apply the 'Times New Roman' font for these cells since the letter spacing in this font is minimal. 

We then copy the formula in Cell C3 to the rest of the cells. Since this is a regular formula, as soon as you change the data in the cells, the in-cell chart is automatically redrawn. Go ahead, and give the above spreadsheet a try. Use the 'Click to Edit' button to interact with the spreadsheet.

Hope you find this useful. If you have any interesting uses of functions, share it with us.

    Access your files securely from anywhere

        All-in-one knowledge management and training platform for your employees and customers.






                              Zoho Developer Community




                                                    • Desk Community Learning Series


                                                    • Digest


                                                    • Functions


                                                    • Meetups


                                                    • Kbase


                                                    • Resources


                                                    • Glossary


                                                    • Desk Marketplace


                                                    • MVP Corner


                                                    • Word of the Day


                                                    • Ask the Experts



                                                              • Sticky Posts

                                                              • What's new in Zoho Sheet: Simplify data entry and collaboration

                                                                Hello, Zoho Sheet community! Last year, our team was focused on research and development so we could deliver updates that enhance your spreadsheet experience. This year, we’re excited to deliver those enhancements—but we'll be rolling them out incrementally
                                                              • New Features: Repeat Last Action, Insert Cut/Copied Rows/Columns and Hyperlink

                                                                You might have noticed the constant updates to Zoho Sheet of late. Here are 3 more features that have been added to Zoho Sheet recently: F4 - Repeat Last Action Insert Cut/Copied Rows and Columns Insert Hyperlink Here is a screen cast demonstrating each of these features. Read further below to learn more about these new features. F4 - Repeat Last Action: You can now repeat the last action you made on your spreadsheet by using the keyboard shortcut, F4. It is quite handy and helps you get your work
                                                              • Introducing Forms in Zoho Sheet

                                                                We hereby bring you the power of ​forms in Zoho Sheet. ​Now, build and create your own customized forms using Zoho Sheet. Be it compiling a questionnaire or rolling out a survey, Zoho Sheet can do it all for you. Forms is an excellent feature that helps you collect information in the simplest of ways and having it in Zoho Sheet takes it a notch higher. Build Simple yet Powerful forms Building forms using Zoho Sheet is fairly simple. The exclusive 'Form' tab lets you create one quickly. Whether you
                                                              • Slicers are now available in Zoho Sheet—filter your data interactively

                                                                At Zoho Sheet, we diligently track user requests and feedback. In line with this, based on extensive user requests, we've integrated Slicers to pivot tables and are delighted to announce its release. Slicers are interactive visual filters that have add,
                                                              • Introducing Data Bars: Graphically represent changes in data within the cells

                                                                Conditional formatting has helped millions of spreadsheet users analyze and highlight their data more efficiently. In addition to the classic rules, color scales, and icon sets available in Zoho Sheet, you can now apply Data Bars, a convenient method


                                                              Manage your brands on social media



                                                                    Zoho TeamInbox Resources



                                                                        Zoho CRM Plus Resources

                                                                          Zoho Books Resources


                                                                            Zoho Subscriptions Resources

                                                                              Zoho Projects Resources


                                                                                Zoho Sprints Resources


                                                                                  Qntrl Resources


                                                                                    Zoho Creator Resources



                                                                                        Zoho CRM Resources

                                                                                        • CRM Community Learning Series

                                                                                          CRM Community Learning Series


                                                                                        • Kaizen

                                                                                          Kaizen

                                                                                        • Functions

                                                                                          Functions

                                                                                        • Meetups

                                                                                          Meetups

                                                                                        • Kbase

                                                                                          Kbase

                                                                                        • Resources

                                                                                          Resources

                                                                                        • Digest

                                                                                          Digest

                                                                                        • CRM Marketplace

                                                                                          CRM Marketplace

                                                                                        • MVP Corner

                                                                                          MVP Corner









                                                                                            Design. Discuss. Deliver.

                                                                                            Create visually engaging stories with Zoho Show.

                                                                                            Get Started Now


                                                                                              Zoho Show Resources

                                                                                                Zoho Writer

                                                                                                Get Started. Write Away!

                                                                                                Writer is a powerful online word processor, designed for collaborative work.

                                                                                                  Zoho CRM コンテンツ




                                                                                                    Nederlandse Hulpbronnen


                                                                                                        ご検討中の方