VBA & Macro Problems

WPS Office VBA Code to Search a Combo Box Value and Copy a Matching Row

Elise WilliamsElise Williams Nov 13, 2026 869 views

Question details

The user wants a VBA macro that selects a customer code from a combo box, searches for that code in another workbook, copies the matching row, and pastes it transposed into a destination sheet.

Product
WPS Office Spreadsheets
Device & OS
not provided
Scenario
Automating a customer code lookup between two workbooks.
Observed behavior
The intended goal is for the macro to open the master workbook, locate the matching row, and paste the result transposed with headings into the destination sheet.
Before you start

Before running the macro, confirm the master workbook path, sheet name, and the column that contains the customer codes. Test with sample files or copies before using production data.

Solution 1Recommended

Create a combo box and button that run a VBA lookup macro

Recommended when you need a reusable worksheet control to select a customer code and copy the matching row transposed.

This approach uses an ActiveX combo box and a command button on the worksheet. The macro opens the master workbook, searches the customer-code column, and writes the matching row plus headings to the destination sheet.

1
Open WPS Spreadsheets and enable the Developer tab

Click the Menu button, choose Options, open Customize Ribbon, enable Developer, and then click OK.

2
Insert a combo box and a command button

On the Developer tab, click Insert, choose Combo Box from the ActiveX controls, and draw it on the worksheet. Repeat the same process to add a Command Button and set its caption to Search.

3
Open the Visual Basic Editor and add a module

On the Developer tab, click Visual Basic, right-click the project in the Project Explorer, choose Insert, and then choose Module. Paste the lookup code into the module.

4
Edit the macro constants and assign the button

Set the master workbook path, master sheet name, search column, and destination sheet name to match your files. Right-click the command button, choose Assign Macro, and select the lookup macro.

5
Run and verify the transposed copy

Select a customer code from the combo box, click Search, and confirm that the matching row is pasted transposed with headings into the destination sheet.

Create a combo box and button that run a VBA lookup macro
Expected result: When the paths and sheet names are correct, the macro pastes the matching row transposed into the destination sheet together with the headings.

Automate the combo box lookup with WPS Office Spreadsheets

You can build the same VBA workflow in WPS Office Spreadsheets: add a combo box and button, assign a lookup macro, and copy a matching row transposed into your destination sheet.

  1. 1. Download and open WPS Office: Download WPS Office from the official site, open WPS Spreadsheets, and load the workbook that will contain the combo box and button.
  2. 2. Enable the Developer tab: Click Menu, choose Options, open Customize Ribbon, enable Developer, and click OK.
  3. 3. Insert controls and paste the VBA code: Insert a combo box and command button, open the Visual Basic Editor, add a module, and adapt the lookup macro to your workbook paths and sheet names.
  4. 4. Run the macro and verify the transposed row: Select a customer code, click the button, and check that the matching row appears transposed with headings in the destination sheet.
Supports Excel VBA lookup logic inside WPS SpreadsheetsOpens and processes .xlsx and .xlsm workbooks while preserving Microsoft Office format compatibilityProvides a familiar Developer tab and Visual Basic EditorFree, lightweight, and easy to set up for customer-code search and transposed paste
microsoft office alternative - wps office

Frequently Asked Questions

Does WPS Office support VBA macros?

WPS Spreadsheets supports VBA and macros in Windows versions. Open the Developer tab and use the Visual Basic Editor to add or edit macro code.

Why does my macro not find the customer code?

Check the master workbook path, master sheet name, search column, and destination sheet name in the code. Also check for leading or trailing spaces, case differences, or numbers stored as text.

Can I use a data-validation list instead of an ActiveX combo box?

Yes. Create a list through Data > Validation, then assign the same lookup macro to a command button or worksheet event.

How do I paste the matching row transposed?

In the VBA code, use PasteSpecial with Transpose set to True, or write the matching cell values directly to the destination range in transposed order.

How do I assign the macro to a button or combo box?

Right-click the button or combo box, choose Assign Macro, select the macro name, and click OK.