View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
uriel78 uriel78 is offline
external usenet poster
 
Posts: 38
Default macro to import file (help with a piece of code)

I actually use a macro to import a txt file with a lot of columns

Below there is a part of the code that allows me to import the file...
I want to import only the first 6 columns (from A to g) and actually I
import all the columns and then erase the exceeding with

Columns("G:IV").Select
Selection.Delete Shift:=xlToLeft

How can I import them without doing the delete procedure...?
I think there is sthg to do with

.TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1)

But I don't understand what....



With ActiveSheet.QueryTables.Add(Connection:=fileToOpen _
, Destination:=Range("A1"))
.Name = "Push"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 850
.TextFileStartRow = 3
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierNone
.TextFileConsecutiveDelimiter = True
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = True
.TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
Columns("G:IV").Select
Selection.Delete Shift:=xlToLeft