Write Quantity and Date to the Next Excel Row Using VBA
Question details
Write the quantity and sale date from cells P1 and Q1 to the next available stock-card row.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- A stock-card worksheet stores quantities in column B and sale dates in column C.
- Observed behavior
- The desired result is to append both values together on the next available row.
Confirm that the worksheet is named Nail Cards, P1 contains the quantity, and Q1 contains the sale date. The macro assumes column B identifies the last stock-card entry and the destination cells in columns B and C are available.
Use VBA to append the quantity and date
Use this macro when all stock-card entries share one list in columns B and C.
The macro finds the last used cell in column B, moves down one row, and copies the values from P1:Q1 to columns B and C. It targets the Nail Cards sheet in the workbook containing the macro.
In Excel, open the workbook and select Developer > Visual Basic.
In the VBA editor, select the workbook, choose Insert > Module, and paste: Sub AddSale() Dim ws As Worksheet Dim nextRow As Long Set ws = ThisWorkbook.Worksheets("Nail Cards") nextRow = ws.Cells(ws.Rows.Count, "B").End(xlUp).Row + 1 ws.Cells(nextRow, "B").Resize(1, 2).Value = ws.Range("P1:Q1").Value End Sub
Select File > Save As and choose Excel Macro-Enabled Workbook (*.xlsm) to retain the VBA code.
Enter a quantity in P1 and a date in Q1, then select Developer > Macros, choose AddSale, and click Run. Check the new entry in columns B and C.

Manage stock-card worksheets in WPS Spreadsheet
WPS Office is a free, lightweight alternative for working with stock-card spreadsheets. Its familiar interface and Excel format compatibility make it easy to move everyday spreadsheet work from Microsoft Office. VBA macro support depends on the WPS version and configuration, so check compatibility before relying on the Excel macro.

Frequently Asked Questions
Why does the macro look for the last used cell in column B?
Column B holds the quantities, so the macro uses it to identify the end of the list. This works when each existing entry has a value in column B and the next row is available in both columns B and C.
Will the macro fill a blank row in the middle of the list?
No. Cells(Rows.Count, "B").End(xlUp) finds the last used cell in column B, so the macro appends below it rather than filling earlier gaps.
How do I make the sale date display correctly?
Select column C, open Home > Number Format, and choose a date format. Make sure Q1 contains a valid Excel date.
Why does the macro ignore the stock-card identifier in R7?
The example searches the entire column B and does not reference R7. For separate card sections, the code must use R7 to identify the correct section and search only within its row boundaries.
What if I cannot run the macro?
Save the workbook as an XLSM file, then check Developer > Macros for AddSale. If Excel blocks the macro, enable content only if you trust the workbook and its source.




