Hello everyone.
In one file we have a macro that collects data from a datafile(other excel) according to the customer number(s).
Here is the code: (the code runs through several fields and gets the sales data according to the customer number in the cell (Range. "D16") and collects it to the CUSTOMER_DATA-sheet)
Dim varFileName1 As String
varFileName1 = Application.ActiveWorkbook.Name
Workbooks.Open Filename:="C:\DATAFILE.XLS"
Dim WB1 As Workbook
Set WB1 = ActiveWorkbook
With WB1.Sheets("DATASHEET")
With .Range("A1:Z65500")
Windows(varFileName1).Activate
.AutoFilter Field:=1, Criteria1:=Sheets("INFOCARD").Range("D16")
.Copy Sheets("CUSTOMER_DATA").Range("A1")
.AutoFilter
End With
End With
WB1.Close savechanges:=False
End If
The problem is that now the code collect the data, but for some reason created 32 000 empty cells also (that is the amount of rows that the DATAFILE.XLS has rows). And the filesize goes up from under 200kb to 2500kb.
Before the code just got the values it found on the search, but now it creates also the empty cell.
Can anyone help me with this one? Please ask if something wasn't clear.
Thanx in advance.
In one file we have a macro that collects data from a datafile(other excel) according to the customer number(s).
Here is the code: (the code runs through several fields and gets the sales data according to the customer number in the cell (Range. "D16") and collects it to the CUSTOMER_DATA-sheet)
Dim varFileName1 As String
varFileName1 = Application.ActiveWorkbook.Name
Workbooks.Open Filename:="C:\DATAFILE.XLS"
Dim WB1 As Workbook
Set WB1 = ActiveWorkbook
With WB1.Sheets("DATASHEET")
With .Range("A1:Z65500")
Windows(varFileName1).Activate
.AutoFilter Field:=1, Criteria1:=Sheets("INFOCARD").Range("D16")
.Copy Sheets("CUSTOMER_DATA").Range("A1")
.AutoFilter
End With
End With
WB1.Close savechanges:=False
End If
The problem is that now the code collect the data, but for some reason created 32 000 empty cells also (that is the amount of rows that the DATAFILE.XLS has rows). And the filesize goes up from under 200kb to 2500kb.
Before the code just got the values it found on the search, but now it creates also the empty cell.
Can anyone help me with this one? Please ask if something wasn't clear.
Thanx in advance.