Fix RefEdit Control Error this.setActiveSheet is not a function in Excel
Question details
The user encounters a functional error when using the RefEdit control to select a data range in a spreadsheet.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Using the RefEdit control within a custom dialog or macro environment to select a range of cells.
- Observed behavior
- The system displays an error stating 'Unable to get data range. this.setActiveSheet is not a function.'
Ensure you have saved a backup copy of your macro-enabled workbook before modifying the VBA code or running an Office repair.
Update and Repair Microsoft Office
Since this error often stems from an internal glitch or corrupted library handling the RefEdit control, repairing the Office installation and applying the latest updates can resolve the issue.
The RefEdit control relies on specific Office libraries. If these become corrupted or outdated, standard functions may fail to execute properly, triggering JavaScript or VBA-related object errors.
Save your work and close all open Microsoft Office applications, including Excel.
Open the Windows Control Panel, select 'Programs', and then click on 'Programs and Features'.
Locate your Microsoft Office installation in the list, right-click it, and select 'Change'. Choose 'Online Repair' and follow the on-screen instructions.
Once the repair is complete, open Excel, navigate to 'File' > 'Account', click on 'Update Options', and select 'Update Now' to ensure you are on the latest build.

Consult Microsoft Q&A for Technical Investigation
If the issue persists after a repair, it may require advanced technical investigation by Excel experts regarding your specific spreadsheet environment.
Try WPS Office for a Smoother Spreadsheet Experience
If you are experiencing persistent VBA or macro errors in Microsoft Excel, consider switching to WPS Office. It is a free, lightweight, and highly compatible alternative that supports advanced spreadsheet functions and macros without the heavy resource load.
- 1. Download WPS Office: Visit the official WPS website to download the free installer.
- 2. Install and Launch: Run the installer and open WPS Spreadsheets.
- 3. Open Your Workbook: Open your existing Excel files directly in WPS Office with full format compatibility.

Frequently Asked Questions
What is the RefEdit control in Excel VBA?
The RefEdit control is a dialog box element used in Excel user forms. It allows users to collapse the dialog box and manually select a range of cells directly from the worksheet using their mouse.
Why am I getting a 'this.setActiveSheet is not a function' error?
This error generally points to a corrupted library reference, an add-in conflict, or a bug within the Office environment. It indicates that the script execution failed because the object reference does not support the 'setActiveSheet' method in the current context.
Can a corrupted Office add-in cause RefEdit errors?
Yes, third-party add-ins or outdated COM add-ins can sometimes conflict with Excel's native dialog controls like RefEdit. Disabling unnecessary add-ins from 'File' > 'Options' > 'Add-ins' can help isolate and resolve the issue.




