I'm trying to figure out if I am able to run a SQL statement when a user clicks on a cell in Excel. If so how?
Thanks,
Use the Worksheet SelectionChange method and you can do it!
In this following code, the macro runs when you click A1 cell.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
L = ActiveCell.Row
C = ActiveCell.Column
If L = 1 and C = 1 Then
*(write your code here)*
End if
End Sub
You can do something like this.
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
If Target.Address = "$A$1" Then
Call MyMacro
End If
End Sub
Then, fire off a Macro to do some kind of import or export. That's what you want to do, right. Please see the links below for several ides of how to import and/or export data between Excel and Access.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.