Have VBA Pull Value from Excel based on a drop down

psulions83

Board Regular
Joined
Nov 16, 2015
Messages
127
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

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.

Forum statistics

Threads
1,224,824
Messages
6,181,186
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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