Query Table - Extract Data From Text File by Column - TextFileColumnDataTypes
Dear All,
I have a question regarding the QueryTable thrugh VBA ..
Basically I am trying to prepare dynamic QuaeryTable which is extracting whole rows of specific columns (There re 300+ columns) in a text file.
In the recorded macro "TextFileColumnDataTypes" part allows us to make selection that to be extracted can be seen below
When I want to change the column to extract I need to modify Array () part of code therefore I decided to create Array part of the code in excel through formula (Let's say in "B7") and then I assigned this to code like this.
.TextFileColumnDataTypes = Range("B7").Value
Now, the problem is when I run the macro, I get an error message (invalid procedure call or argument - 5) and macro does not work. It seems the problem is VBA returns this to
Please note that there are quotation marks and this could be related to variable types but unfortunately I could not find a way to get this without quotation ("") marks.
My questions; is there a solution for this or is there a simple way to get specific column (it’s a kind of HLOOKUP) of a text box.
Just for the purpose of someone needs help in the same situation, the solution can be seen below.
All the best
Cerkes
---Added this code to the macro above--------------------
Dim strarray As Variant
Dim iarray() As Integer
Dim i As Integer
strarray = Split(Range("B7").Value, ",")
ReDim iarray(UBound(strarray))
For i = 0 To UBound(strarray)
iarray(i) = strarray(i)
Next i
---- made a change in the code like below-----------
With ActiveSheet.QueryTables.Add(Connection:= _
.............
.............
.............
.............
.............
.............
.............