CMIIandExcel
Board Regular
- Joined
- Sep 4, 2009
- Messages
- 190
Hi all
I have 3 workbooks:
1 - Macros are in a Control Workbook
2 - Data source which is a CSV file
3 - Destination for the data which is a preformatted template
all three workbooks are open at the time of the code running
I am using the code below to extract the data from the source workbook and then add this data into the template file.
The problem I have is that I cannot get the data into the template(Destination sheet), it places the data into range A1 of the source file
What do i need to change to place the data into another workbook?? i have tried a few things but nothing seems to work.
Regards
Mike
I have 3 workbooks:
1 - Macros are in a Control Workbook
2 - Data source which is a CSV file
3 - Destination for the data which is a preformatted template
all three workbooks are open at the time of the code running
I am using the code below to extract the data from the source workbook and then add this data into the template file.
The problem I have is that I cannot get the data into the template(Destination sheet), it places the data into range A1 of the source file
What do i need to change to place the data into another workbook?? i have tried a few things but nothing seems to work.
Regards
Mike
Code:
Public Sub GetDelimitedData(wbdestination As Workbook, wsDestination As Worksheet, strDestinationCell As String, _
strSourceFileAddress As String, arrDataTypes() As Long)
With wsDestination.QueryTables.Add(Connection:= _
"TEXT;" & strSourceFileAddress, Destination:= _
wsDestination.Range(strDestinationCell))
.Name = ""
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = False
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 850
.TextFileStartRow = 2
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = True
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = arrDataTypes()
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
End Sub