Have VBA Pull Value from Excel based on a drop down

psulions83

Board Regular
Joined
Nov 16, 2015
Messages
126
Hi,

I have a drop down in excel that I want the value in that box to run a certain macro in my access dB when I press a button. So I pick a value in my dropdown then click the button to kick off the macro. If there is a way that when you click a button you can be prompted with these drop down values and does the same thing I am good with that approach too. My code is below.

Code:
Sub accessMacro()


   Dim appAccess As Access.Application


   Set appAccess = New Access.Application
   
   'Debug.Print ThisWorkbook.Path & "\Access dB.accdb"
   
   appAccess.OpenCurrentDatabase ThisWorkbook.Path & "\Access dB.accdb"
   
   appAccess.Visible = False
   
   Application.DisplayAlerts = False
   
  [COLOR=#ff0000] appAccess.DoCmd.RunMacro "Mcr_All_"[/COLOR]     'Macro to run the table loads. Bascially in my dropdown if I had values I want this to be more dynamic.  All the Macros are named Mcr_All_abc
   
   ActiveWorkbook.refreshAll


   appAccess.CloseCurrentDatabase
     
   ActiveWorkbook.Activate
   
   MsgBox "Done", vbCritical
   
   ActiveWorkbook.refreshAll


End Sub
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).

Forum statistics

Threads
1,215,063
Messages
6,122,927
Members
449,094
Latest member
teemeren

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top