LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
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


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Interpretation of a piece of code FARAZ QURESHI Excel Discussion (Misc queries) 3 December 30th 07 11:29 PM
What is wrong with this vba piece of code? Jo[_2_] Excel Discussion (Misc queries) 4 October 4th 07 05:01 PM
VB Code or Excel macro to run Query/Import on Access file Harry[_8_] Excel Programming 13 February 22nd 05 07:27 PM
changing a piece of code Ajit Excel Programming 0 September 17th 04 02:45 PM
Query on small piece of code Mike[_65_] Excel Programming 7 March 4th 04 03:23 PM


All times are GMT +1. The time now is 02:41 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"