MistakesWereMade
Board Regular
- Joined
- May 22, 2019
- Messages
- 103
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.
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
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