Running VBA script every time a linked cell is updated through a combo box selection.

MistakesWereMade

Board Regular
Joined
May 22, 2019
Messages
95
So I have an issue in my excel file where I have a cell that is bound with a combo box. Every time the combo box selection is chosen, the linked cell will, of course, automatically contain the contents of the combo box. I then want my VBA script to automatically open an excel file on my desktop that corresponds with each time a combo box option is selected. However, my current script is missing the ability to automatically open the excel files. The script will only register that linked cell's contents have changed when I manually click on the linked cell, go the formula box, and press enter. I want my script to allow anyone to go to the combo box, make a selection which updates the linked cell, the script to realize the change, and then correspondingly open the right excel file. I've attached my current code.
Code:
Private Sub Worksheet_Change(ByVal Target As Range)


On Error Resume Next
    
Dim varCellvalue As Long
 
    If Target.Address = "$F$2" Then


        Var = Range("F2").Value
      
        Workbooks.Open "C:\Users\MyUser\Desktop" & Var & ".xlsx"
         
    End If
     
End Sub
 
Last edited by a moderator:

Some videos you may like

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
34,796
Office Version
365, 2019, 2016, 2010
Platform
Windows, MacOS
Depending on the type of combobox, why not just assign a macro to it, or use its Change event?
 

Watch MrExcel Video

Forum statistics

Threads
1,095,375
Messages
5,444,102
Members
405,267
Latest member
bolton70

This Week's Hot Topics

Top