Finance

Charts

Statistics

Macros

Search

How to use the REPT function in Excel

This function repeats a text string a specified number of times.

Syntax
REPT(text; number_times)

Arguments

  • text (required): The character or string to repeat.
  • number_times (required): A positive number specifying repetition count.

Background
The REPT() function is useful for:

  • Creating repeated patterns (e.g., filling cells with characters).
  • Generating in-cell bar charts or visual indicators.

Key Notes:

  • Returns «  » (empty string) if number_times is 0.
  • Truncates decimal values (e.g., 3.9 becomes 3).
  • Returns #VALUE! if:
    • number_times is negative.
    • Result exceeds 32,767 characters.

Example: Aligning Names and Scores

  1. Setup:
    • Names in F6:F16, scores in G6:G16.
    • Goal: Combine in H6:H16 with aligned spacing.
  2. Step 1: Calculate Max Length
    Select I6:I16 and enter (as an array formula with Ctrl+Shift+Enter):

=MAX(LEN(F6:F16) + LEN(G6:G16)) + 1

Result: Determines maximum combined length for alignment.

  1. Step 2: Align Text
    In H6, enter:

=F6 & REPT( » « , I6 – LEN(F6) – LEN(G6)) & G6

How it works:

    • Repeats spaces ( » « ) to pad between names and scores.
    • Adjusts spacing dynamically based on each row’s text length.

0 0 votes
Évaluation de l'article
S’abonner
Notification pour
guest
0 Commentaires
Le plus ancien
Le plus récent Le plus populaire
Online comments
Show all comments
Facebook
Twitter
LinkedIn
WhatsApp
Email
Print
0
We’d love to hear your thoughts — please leave a commentx