VBA & Macro Problems

Excel VBA Macro to Enter Numbers 1 to 48 from Any Cell

Steven ParkerSteven Parker Dec 2, 2026 869 views

Question details

The user needs an Excel VBA macro that enters numbers 1 through 48 downward from the selected cell.

Enter Numbers 1 to 48 from Any Cell with an Excel VBA Macro
Product
Microsoft Excel
Device & OS
not provided
Scenario
The user wants to run the same macro from different starting cells rather than use a fixed worksheet range.
Observed behavior
The desired result is a column of consecutive numbers from 1 to 48 beginning at the active cell.
Before you start

Choose a starting cell with at least 47 rows available beneath it, and check that the target cells can be edited. The macro will overwrite existing values in those 48 cells.

Solution 1Recommended

Fill 1 to 48 Downward from the Active Cell with VBA

Use this macro when the starting cell changes each time you run it.

The macro uses ActiveCell as its starting point and Offset to write each number one row below the previous one.

1
Open the VBA editor

In Excel, open the Developer tab and select Visual Basic. If the tab is hidden, enable it through Excel's ribbon settings.

2
Insert the macro

In the VBA editor, select Insert > Module and paste: Sub FillNumbers() Dim i As Long For i = 1 To 48 ActiveCell.Offset(i - 1, 0).Value = i Next i End Sub

3
Select a starting cell

Return to the worksheet and click the cell where the number 1 should appear.

4
Run the macro

Select Developer > Macros, choose FillNumbers, and select Run. Excel fills the selected cell and the 47 cells below it.

Fill 1 to 48 Downward from the Active Cell with VBA
Save the macro: To keep the VBA code, use File > Save As and choose Excel Macro-Enabled Workbook (*.xlsm). Enable macros only when you trust the workbook.
Fill a number series without VBA

Create the Same Number Series in WPS Spreadsheets

Use the fill handle in WPS Spreadsheets to enter 1 through 48 from any suitable starting cell without writing a macro.

  1. 1. Open your spreadsheet: Open WPS Spreadsheets and create a workbook or open an existing Excel file.
  2. 2. Enter the first two numbers: Click the starting cell, type 1, and enter 2 in the cell directly below it.
  3. 3. Select both cells: Drag across the two cells containing 1 and 2 to select them.
  4. 4. Extend the series: Drag the fill handle at the bottom-right corner of the selection downward until the series reaches 48.
Fill a consecutive number series from a cell you chooseNo VBA code is needed for a one-time fillOpen and edit Microsoft Excel formats, including XLSX and XLSUse a familiar spreadsheet interface
microsoft office alternative - wps office

Frequently Asked Questions

How do I change the starting cell for the macro?

Click a different worksheet cell before selecting Developer > Macros and running FillNumbers. The selected cell receives 1.

Will the macro overwrite existing data?

Yes. It replaces values in the active cell and the 47 cells below it, so check the target range before running it.

Why can't the macro fill from the bottom of the worksheet?

The starting cell must have at least 47 worksheet rows beneath it. Choose a higher starting cell if the series would extend beyond the last row.

How can I keep the macro in my workbook?

In Excel, select File > Save As and choose Excel Macro-Enabled Workbook (*.xlsm). A standard XLSX file does not retain VBA macros.