I am trying to get a database from Workbook B to autofilter using some input from Workbook A. I am building the macro in Workbook A.
I have the following: Workbook A - Document were you start working Worrkbook B - Database, the final objective of this code is to import some info from Workbook B to Workbook A
I need the following:
- By double clicking in a column from workbook A, workbook B should open (done)
- The clicked value from workbook A will be saved as a variable, lets call it input_db (done)
- Workbook B will autofilter based on input_db (not done, help required here!)
- The required data is selected from workbook B and imported to workbook A, preferably with a double click as well (not done yet, but if you have any suggestion for this, Ill be gratefull ;))
The process should be repeated several times in a row.
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Dim input_row, input_column As Integer
Dim input_db As String
Dim wbB, wbA As Workbooks
If Not (Application.Intersect(ActiveCell, [Links]) Is Nothing) Then 'Links is the name of the range where I need the code to be active
If ActiveCell.Value <> "" Then
input_row = ActiveCell.row
input_column = ActiveCell.Column
input_db = ActiveCell.Value
Set database = Workbooks.Open("Workbook B location")
ActiveWorkbook.ActiveSheet.Range("A9").AutoFilter Field:=1, Criteria:=input_db ' This bit doesnt work as expected
End If
End If
End Sub