Insert Rows or Cells in WPS Office Excel Based on a Number in Another Cell Using VBA
Question details
The user needs to insert Excel rows or cells automatically based on a number entered in another cell, such as adding one row or cell for each meeting count entry.

- Product
- WPS Office Excel
- Device & OS
- not provided
- Scenario
- A user is building a meeting schedule and needs the rows or cells beside a meeting type to match a meeting count entered in another cell.
- Observed behavior
- Excel formulas cannot physically insert rows or cells; a VBA macro is required to read the count and insert the target range.
Make sure the count cell and the target insertion cell are clearly identified in the worksheet, and save a backup copy before running the macro because inserting cells shifts existing data and formulas.
Use a VBA macro to insert rows or cells based on a number in another cell
Use this solution when you need automatic insertion after a user enters a number, such as a meeting count, and manual copying is too slow or error-prone.
WPS Office Excel supports VBA macros, so you can automate cell insertion without manually copying and inserting every time.
Inserting cells shifts existing data and formulas, so test the macro on a copy or a clearly defined target range first.
In WPS Office Excel, click the Developer tab and then click Visual Basic. If the Developer tab is not visible, press Alt+F11 to open the VBA editor directly.
In the VBA editor, click Insert and then click Module to create a new module.
Paste a macro that reads the count cell, validates that it is a positive number, and inserts that many rows or cells beside the meeting type. For example, the macro can read cell B2 as the count and insert from cell C5 using Resize and Insert Shift:=xlDown.
Change the count cell and the insertion start cell in the code to match your worksheet layout before running the macro.
Return to the worksheet, click Developer, click Macros, select the macro, and then click Run. Confirm that the correct number of rows or cells is inserted.

Automate Row and Cell Insertion in WPS Office Excel with VBA
Use WPS Office Excel's VBA editor to create a macro that reads a number from another cell and inserts the required rows or cells automatically, reducing manual editing and shifting errors.
- 1. Download WPS Office: Download WPS Office from the official WPS site and install it on your Windows PC.
- 2. Open the Excel workbook: Open your workbook in WPS Office Excel and enable the Developer tab if it is not already visible.
- 3. Create the VBA macro: Press Alt+F11 to open the VBA editor, insert a module, and paste a macro that reads the count cell and inserts that many rows or cells at the target range.
- 4. Run and verify: Return to the worksheet, click Developer, click Macros, select the macro, and then click Run. Check that the correct number of rows or cells has been inserted.

Frequently Asked Questions
Can Excel formulas insert rows automatically based on a cell value?
No. Excel formulas can return values, but they cannot physically insert rows or cells. You need a VBA macro in WPS Office Excel to read the value and perform the insertion.
How do I open the VBA editor in WPS Office Excel?
Click the Developer tab and choose Visual Basic, or press Alt+F11 to open the VBA editor directly.
Will inserting cells shift my existing formulas and data?
Yes. Inserting cells shifts cells down or right depending on the insertion method, so define the target insertion point and test on a copy.
Can I use Excel VBA code in WPS Office?
WPS Office supports common Excel VBA syntax and macro-enabled workbooks, so many Excel macros can be opened and edited in WPS Office Excel.
What should I do before running the macro?
Save a backup copy and confirm that the count cell and target insertion cell are referenced correctly in the macro.




