How to Use an Excel Form Control Button to Add a New Record with VBA
Question details
The user wants to use a Form Control button to trigger a VBA macro that prompts for a value, inserts it into the next available row, records the current date, and copies down relevant formulas.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Automating data entry in a spreadsheet using a macro assigned to a clickable Form Control button.
- Observed behavior
- A macro must be correctly created in a standard module, linked to a Form Control button, and executed to successfully add new records without errors.
Ensure that your Developer tab is enabled in the ribbon and remember to save your file as a Macro-Enabled Workbook (.xlsm) to prevent losing your VBA code.
Create and Assign a VBA Macro to a Form Control Button
Create a public Sub procedure in a standard VBA module and assign it to a Form Control button to automate data entry.
Form Control buttons must call a public macro stored in a standard module. This differs from ActiveX controls, which typically use Private event handlers inside worksheet modules.
Press 'Alt + F11' on your keyboard to open the Visual Basic for Applications (VBA) editor.
In the VBA editor, click 'Insert' in the top menu and select 'Module' to create a new standard module.
Paste your macro code into the module window. Ensure the macro begins with 'Sub NewRecord()' and contains the logic for capturing the input box value, finding the last row using 'Rows.Count.End(xlUp)', and applying offsets.
Return to your worksheet, go to the 'Developer' tab, click 'Insert', and choose 'Button (Form Control)'. Draw the button on your sheet.
Once you release the mouse button, the 'Assign Macro' dialog will appear. Select your 'NewRecord' macro and click 'OK'.

Use WPS Spreadsheet Macros to Automate Data Entry
WPS Spreadsheets provides robust support for VBA macros, allowing you to create Form Control buttons, write custom scripts, and automate repetitive data entry tasks just like in Microsoft Excel.
- 1. Open the Developer Tab: Launch WPS Spreadsheets, open your file, and navigate to the Developer tab on the ribbon.
- 2. Open the VBA Editor: Click on 'Visual Basic' or press Alt+F11 to open the VBA editor and insert a new standard Module.
- 3. Insert a Form Control Button: Back in the spreadsheet, click 'Insert' under the Developer tab, select the Button control, draw it on your sheet, and assign your macro to it.

Frequently Asked Questions
Why does my macro not appear when I try to assign it to the Form Control button?
Ensure your macro is written as a public 'Sub' in a standard Module. If it is written as a 'Private Sub' or placed inside a Worksheet object module, it will not appear in the Assign Macro dialog box.
What is the difference between Form Controls and ActiveX Controls?
Form Controls are simpler, built directly into the spreadsheet interface, and are designed to trigger standard public macros. ActiveX Controls have more customizable properties and use private event macros (like CommandButton_Click) located directly in the specific sheet's code module.
How do I find the next empty row using VBA?
You can use the expression 'Range("A" & Rows.Count).End(xlUp).Offset(1, 0)' in your VBA code. This dynamically locates the last used cell in column A and offsets it by one row down to target the first empty cell.




