jonastiger
Member
Hi
I wonder if someone can help me with this:
I have found this code and I need to fit it to my needs but I don't how to do:
There´s a file (Closed.xlsx) which is daily exported from a server, with variable size each day (>100000 rows). I need to filter and copy specific data (cols 1,3,8,24,27) from that file based on criteria (named range called "TECH" which information exists in col 8). TECH has the names of a specific technician team (John, Richard, Charles, ...). Filtered Data will be pasted in Open.xlsm Sheet "Report" (same folder).
I work with Excel 2013/2016
My goal is: open Workbook "Open.xlsm" Sheet "Report" and automatically update filtered data
I did search and ask for help to other sources, but no success.
Thank you very much for your attention.
JT
I wonder if someone can help me with this:
I have found this code and I need to fit it to my needs but I don't how to do:
There´s a file (Closed.xlsx) which is daily exported from a server, with variable size each day (>100000 rows). I need to filter and copy specific data (cols 1,3,8,24,27) from that file based on criteria (named range called "TECH" which information exists in col 8). TECH has the names of a specific technician team (John, Richard, Charles, ...). Filtered Data will be pasted in Open.xlsm Sheet "Report" (same folder).
I work with Excel 2013/2016
My goal is: open Workbook "Open.xlsm" Sheet "Report" and automatically update filtered data
I did search and ask for help to other sources, but no success.
Code:
Option Explicit
'you can extract data from a closed file by using an
'XLM macro. Credit for this technique goes to John
'Walkenback > http://j-walk.com/ss/excel/tips/tip82.htm
Sub GetDataDemo()
Dim FilePath$, Row&, Column&, Address$
'change constants & FilePath below to suit
'***************************************
Const FileName$ = "Closed.xlsx"
Const SheetName$ = "DataList"
Const NumRows& = 100000 'Need to configure range from A1 to last row non blank to get range exact size
Const NumColumns& = 28 'Or setup only cols 1,3,8,24,27
FilePath = ActiveWorkbook.Path & "\"
'***************************************
DoEvents
Application.ScreenUpdating = False
If Dir(FilePath & FileName) = Empty Then
MsgBox "The file " & FileName & " was not found", , "File Doesn't Exist"
Exit Sub
End If
For Row = 1 To NumRows
For Column = 1 To NumColumns
Address = Cells(Row, Column).Address 'How to setup named range
Cells(Row, Column) = GetData(FilePath, FileName, SheetName, Address)
Columns.AutoFit
Next Column
Next Row
ActiveWindow.DisplayZeros = False
End Sub
Private Function GetData(Path, File, Sheet, Address)
Dim Data$
Data = "'" & Path & "[" & File & "]" & Sheet & "'!" & _
Range(Address).Range("A1").Address(, , xlR1C1)
GetData = ExecuteExcel4Macro(Data)
End Function
Thank you very much for your attention.
JT