Excel: create multiple rows based on "amount" column

Abstract: Expand single rows into multiple rows based on an amount column using Power Query or VBA.

Created: 2026-09-23 by
To create multiple rows in Excel based on an "amount" column, you can use the Power Query Editor to unpivot or expand data, or employ a VBA macro for immediate sheet modification. The most robust non-code method involves loading your table into Power Query, adding a custom column with a list of numbers from 1 to the amount value, and then expanding that list. This approach ensures your dataset remains dynamic and easily refreshable when new entries are added.

Understanding the Data Expansion Problem

When working with tabular data, it is common to encounter situations where a single row represents multiple instances of an item. For example, if you have an inventory list where one row indicates you have 5 units of a specific product, standard reporting tools often require five separate rows to accurately reflect stock levels or transaction history. Manually copying and pasting rows for large datasets is inefficient and prone to error. Instead, automating this process allows for cleaner data structures that are compatible with pivot tables, charts, and database imports.

Method 1: Using Power Query (Recommended)

Power Query is built into modern versions of Excel and provides a powerful way to transform data without altering the original source. This method is ideal because it creates a repeatable workflow. If your source data changes, you simply right-click the query and select "Refresh" to update the expanded table.

Step-by-Step Implementation

  1. Load Data to Power Query: Select your entire data range, including headers. Go to the Data tab on the ribbon and click From Table/Range. Ensure the "My table has headers" box is checked and click OK. This opens the Power Query Editor window.
  2. Add a Custom Column: In the Power Query Editor, go to the Add Column tab and select Custom Column. Name the new column something descriptive like Sequence. In the formula bar, enter the following expression: {1..[Amount]}. Replace [Amount] with the actual name of your quantity column. This generates a list of numbers from 1 up to the value in that row.
  3. Expand the List: Click the expand icon (two arrows pointing away from each other) located at the top-right of the new Sequence column header. Choose to expand the values into new rows. Uncheck "Use original column name as prefix" if desired, and click OK.
  4. Clean Up: You may now hide the Sequence column if it is not needed for final output. Select the columns you wish to keep, right-click, and choose Remove Other Columns to tidy up the view.
  5. Output to Excel: Go to the Home tab in the Power Query Editor and click Close & Load. This will create a new worksheet containing the expanded data.

Method 2: Using VBA Macros

If you need to perform this action directly on the current sheet without creating a separate query table, a VBA macro is the most efficient solution. This script iterates through each row, calculates how many times to duplicate it, and inserts the necessary rows immediately below.

To implement this, press Alt + F11 to open the Visual Basic Editor. Insert a new module and paste the following code:

Sub ExpandRowsByAmount()
    Dim ws As Worksheet
    Dim lastRow As Long
    Dim i As Long
    Dim amountVal As Integer
    
    Set ws = ActiveSheet
    ' Assume Amount is in column B, starting from row 2
    lastRow = ws.Cells(ws.Rows.Count, "B").End(xlUp).Row
    
    ' Loop backwards to handle row insertion correctly
    For i = lastRow To 2 Step -1
        amountVal = ws.Cells(i, 2).Value
        
        ' Check if value is valid and greater than 1
        If IsNumeric(amountVal) And amountVal > 1 Then
            ws.Rows(i + 1).Resize(amountVal - 1).Insert Shift:=xlDown
            ' Copy the original row's data to the new rows
            ws.Rows(i).Copy Destination:=ws.Rows(i + 1).Resize(amountVal - 1)
        End If
    Next i
End Sub

This code assumes your amount data is in column B. Adjust the column index (Cells(i, 2)) and the starting row logic if your layout differs. Running this macro will instantly restructure your visible data. Note that this modifies the active sheet permanently, so save your work before executing.

Handling Edge Cases and Errors

When expanding rows, several edge cases can cause issues. First, ensure there are no blank cells in the amount column. Blank cells will result in zero-length lists in Power Query or errors in VBA. It is best practice to replace blanks with zeros using Ctrl+H find and replace before processing. Second, be mindful of memory limits. Expanding a dataset with millions of rows can crash Excel. Always test with a small subset of data first.

Additionally, consider how this expansion affects downstream formulas. If you have complex calculations referencing these rows, they may need adjustment to account for the increased row count. For instance, absolute references might need to become relative ones depending on your analysis needs. You might also want to add a unique identifier to each new row to track which original record it belongs to, especially if merging data later.

For related data manipulation tasks, such as filling cells based on other columns, you may find our guide on Filling an Excel Cell based on data in two other cells helpful for maintaining consistency across your newly created rows.

Frequently Asked Questions

Can I do this without Power Query or VBA?

No native Excel function exists to automatically duplicate rows based on a numeric value. Manual copy-pasting is the only alternative, but it is not scalable for large datasets. Third-party add-ins like Kutools for Excel offer similar features if you prefer a GUI-based tool over building queries or macros.

What happens if my amount column contains text?

Both Power Query and the provided VBA script require numeric input. If your column contains text or errors, the process will fail or return unexpected results. You should clean the data by converting text numbers to actual numbers using the Text to Columns wizard or the VALUE() function before attempting expansion.

How do I undo the expansion if I make a mistake?

If using Power Query, you can simply delete the query step in the Applied Steps pane on the right side of the editor, or delete the output table entirely. If using VBA, Excel does not support multi-step undo for macros. You must rely on your saved backup file or manually reverse the changes, which is why testing on a copy of your data is crucial.

Will this method preserve formatting?

Power Query preserves basic cell formatting but does not carry over complex conditional formatting rules or chart objects. VBA copies the raw values and basic formatting of the source row to the new rows. If you need specific styling applied to all new rows, you may need to apply a table style or format after the expansion is complete.

Is there a limit to how many rows can be created?

Excel has a maximum row limit of 1,048,576 per worksheet. If your total expanded row count exceeds this limit, you will receive an error. In such cases, consider splitting your data into multiple sheets or databases, or filtering out records with very high amounts before processing.

Latest News

How to Display Output of xterm Command in Terminal Screen using Cron

Resolve the inability to display xterm output in a terminal screen from cron by redirecting logs or using wall instead of insecure X11 workarounds.

Read More
Expose Local Server on VPS Preserving Real Client IPs (OS Level)

Resolve VPS logging showing only gateway IPs by configuring reverse proxies to forward real client addresses via X-Forwarded-For headers.

Read More
How to Clear Recent Files History in Linux without Deleting Actual Files?

Clear recent files history in Linux by deleting ~/.local/share/recently-used.xbel without removing the actual files.

Read More
Best HDD Copy Strategy: Manually Syncing and Rewriting Scratch

Resolve data drift between two 4TB hard drives by using rsync with the --delete flag to manually sync and rewrite scratch data for an exact mirror.

Read More
Understanding Bash Prompt Abbreviations: An Overview

Resolve repetitive typing errors by creating and persisting Bash aliases in the .bashrc file for improved command-line efficiency.

Read More
Free Tools and Methods to Log Real-Time Performance Details in Task Manager

Log real-time CPU and memory metrics to CSV files using Windows Performance Monitor Data Collector Sets to troubleshoot system slowness.

Read More
Contact Qatar Airways Customer Service: Phone Number, Help Center, and More

Resolve urgent Qatar Airways reservation issues like flight changes and baggage claims using the US phone number +1801-855-5905 or online self-service tools.

Read More
Windows 11: Alt Codes Displaying Wrong Characters - Solutions

Resolve Windows 11 Alt codes showing wrong characters by verifying the US keyboard layout and enabling Num Lock.

Read More
Run Programs with Elevated Privileges: A Comprehensive Guide

Eliminates the need to type sudo for frequent administrative tasks by configuring .bashrc aliases or functions.

Read More
Dynamically Changing Dates in Excel Formulas Using Cells

Eliminate manual date updates in Excel by using cell references to create dynamic formulas that automatically adjust calculations when input dates change.

Read More
Granting Edit Access to a Specific Excel Sheet in an Office 365 User Email ID-Based Login

Excel Online lacks native sheet-level permissions, so users must split workbooks or use worksheet protection to isolate edit access for specific tabs.

Read More
Creating Network Load on Local Wi-Fi from One PC

Generate sustained Wi-Fi bandwidth load from a single PC using a VM SFTP server to test router stability and throughput.

Read More
Changing the Default Editor for Batch Files in Windows 11's File Explorer

Resolve the issue of batch files opening in Notepad by changing the default editor to a preferred application like VS Code.

Read More
Gain WiFi Connection Minutes Before Losing it by Changing MAC Address

Bypass MAC address filtering to restore WiFi connectivity temporarily when a device is blocked by network administrators.

Read More
Photos Folders Turned Black: Troubleshooting Picture Applications on Windows

Resolve black screens in Windows Photos by resetting the app, updating graphics drivers, and repairing system files.

Read More
Troubleshooting High CPU Temperature Values: A Step-by-Step Guide

Resolve high CPU temperatures and thermal throttling by monitoring with Speedfan, cleaning dust from cooling components, and replacing degraded thermal paste.

Read More
Make cURL establish TLS connection with CA unknown

Resolve cURL TLS connection failures with unknown or self-signed certificates by using the --insecure flag to bypass CA validation.

Read More
Troubleshooting Incorrect Network Metrics Values in Grafana, Prometheus, InfluxDB, and Telegraf

Fix incorrect network metrics in Grafana, Prometheus, InfluxDB, and Telegraf by verifying interface selection, resolving unit mismatches, and handling counter resets.

Read More
Start Another Terminal Window (cmd.exe) Windows Repair/Troubleshoot

Provides step-by-step instructions to access the Windows Command Prompt via bootable media for advanced system repair and troubleshooting.

Read More
Thinkpad P1 Gen 6: Sudden Thunderbolt 3 Dock USB-C Charging Stopped Working

Resolve sudden Thunderbolt 3 dock USB-C charging and internet failure on ThinkPad P1 Gen 6 by updating firmware, resetting the dock, and adjusting power settings.

Read More
ASUS Windows 11 Laptop: Internet Connection Issue with Hotspot

Resolve ASUS Windows 11 laptop spinning wheel issue when connecting to mobile hotspot by resetting network stack, disabling IPv6, and adjusting power settings.

Read More
Developing iOS Project with Firebase: Logging in and Sending Push Notifications

Integrates Firebase to enable secure user authentication and push notifications in iOS applications.

Read More
Troubleshooting Bash Script with Suspected Issues of Spaces, Dashes, Filenames and Quoting

Resolve Bash script failures caused by word splitting, globbing, and special characters in filenames by applying proper quoting techniques.

Read More
Populating OneDrive Folder for Local Backup without Affecting Remote Files

Prevent OneDrive from deleting remote files during Windows reinstallation by unlinking the account or using symbolic links to isolate local data.

Read More
Force First Frame as Keyframe Without Re-encoding: A Quick Solution

Resolve inaccurate seeking and playback glitches by re-encoding video to ensure the first frame is a valid keyframe.

Read More
Find Information in Database Using WSL (Ubuntu) on Windows-10

Resolve database connection issues from WSL Ubuntu on Windows 10 by configuring client tools and network access to query remote or local servers.

Read More
Configuring a New Router with Different Networks: One Family, One Guest

Resolve IP conflicts and isolate guest traffic by configuring a second router with a distinct subnet via its WAN port.

Read More
Quickly Open Multiple Stock Websites with a Single Command

Solve the problem of manually opening multiple stock research websites by creating a single command to launch them simultaneously on Windows, macOS, or Linux.

Read More
Improved Adobe Acrobat Search Experience: Access Advanced Search with Ease

Access advanced search filters like case sensitivity and regex in Adobe Acrobat by clicking More Options in the Find bar.

Read More
Port Forwarding VM via OpenVPN: A Comprehensive Guide

Configure OpenVPN server and iptables to forward specific ports from VPN clients to a virtual machine's internal IP address.

Read More
Understanding Partitions in the 1980s: A Look Back at MS-DOS and Master Boot Record

Explains how the Master Boot Record and partition table enabled MS-DOS to manage multiple disk volumes on a single physical drive.

Read More
Windows 10 Enterprise: Keyboard Not Detected in Managed Organization with Admin Privileges

Resolve Windows 10 Enterprise keyboard detection failures caused by Group Policy restrictions, driver corruption, or USB enumeration errors.

Read More
Can't Find x86_64 Versions of Applications on MacOS arm64 (M1)

Resolve missing x86_64 app issues on M1 Macs by installing Rosetta 2 and reinstalling apps as universal binaries.

Read More
How to Hide Installation Source for an Android App

Manage Android app installation source visibility by using USB transfers or file managers to reduce browser traces and isolate data via work profiles.

Read More
Connecting Momentus 4200.2 ST9808210A Hard Drive via USB Cable

Resolve inability to access Seagate Momentus 4200.2 ST9808210A hard drive by connecting it via USB using a compatible SATA-to-USB adapter and configuring the disk in Windows.

Read More