Skip Column When Importing Text File
Sep 22, 2007
This question is mostly academic, but I do hope someone out there has an answer. I am using code to open a text file. Since the first column is always blank, I would like to start the import at column 2. I think this can be accomplished with the following
Workbooks.OpenText Filename:=sFileName, Origin:=437, StartRow:=1, DataType:=xlDelimited, _
FieldInfo:= Array(Array(1, 9))
However, according to VB help file,
If you specify that a column is to be skipped, you must explicitly state the type for all remaining columns or the data will not parse correctly.
I haven't seen any problems, but I hate to use code that isn't supposed to work, even if it does. Does anyone know what problems could be caused by not explicitly stating the type for the remaining columns? Question 2: (I know, one per thread, but they are very much related. I will move to new thread if need be). If I don't know the number of columns, how can I explicitly state their type? For example, if I knew I had 4 columns, I would use:
Workbooks.OpenText Filename:=sFileName, Origin:=437, StartRow:=1, DataType:=xlDelimited, _
FieldInfo:=Array(Array(1, 9), Array(2, 1), Array(3, 1), Array(4, 1))
What do I use for a variable number of columns?
The default type of 1 (xlGeneralFormat) is fine for all of my columns.
View 5 Replies
ADVERTISEMENT
Jun 26, 2007
i try to input an txt into a excel spreadsheet, how do skip to certain lines or number? for example if the txt is like
1,2,3,4,5,6,7,8
and i want the excel sheet to start at the the third number
3
4
5
6
7
8
View 8 Replies
View Related
Oct 22, 2009
I have macro that exports certain range to text file. It goes through first to last row and exports it to Text file. Here is the part of the
For Each myRecord In Range("A2:A" & Range("A" & Rows.Count).End(xlUp).Row)
With myRecord
For Each myField In Range(.Cells, Cells(.Row, Columns.Count).End(xlToLeft))
sOut = sOut & DELIMITER & DEL & myField.Text
Next myField
Print #nFileNum, Mid(sOut, 2)
sOut = Empty
End With
Next myRecord
The problem is that sheets might by empty. I would like to add something to this code ( I guess some IF condition) so that all blank rows are skipped and not exported to text file.
View 9 Replies
View Related
Dec 1, 2007
I created a vb macro to open a text file then process the file then close the file. Here is my problem:
Problem: THe text file has rows of data in it as follows
5155111111551511111111111511111111111111111
This row of text gets converted to
5.16E+42
because excel treats the row of text as a number but i dont want it to do this transition.
When i save the file and then reopen it using say NOTEPAD i see 5.16E+42 and not the long string of text.
View 9 Replies
View Related
Jul 7, 2006
importing a text file. 3 times per day, I pull a report off a website and save it as a txt file. Typically, the data consists of approx 2000 customer ID's, and their respective data. When I import the data into Excel, it uses 2 or 3 rows to list information for each customer ID. I need a to seperate out only the customers ID which are 9 numbers long (no text in the ID), their SS #'s, and are listed as "FUL Request" or "PTR Request".
Since the data takes up 2 or 3 rows, the "Text to Column" feature does not work.
So the VBA should be able to look at each row, and if it has a 9 number customer ID in the row directly above it, and meets all other criteria, them post the customer ID number, the SS# and the verbiage "FUL Request" or "PTR Request" onto a seperate sheet.
Or the VBA can simply delete the rows that don't meet the criteria listed above.
View 3 Replies
View Related
Oct 3, 2006
I am using Chip Pearson's method of importing a text file into Excel (found at http://www.cpearson.com/excel/imptext.htm )
It works great except for one aspect. Two of my columns of data are in the format "dd/mm/yyyy hh:mm:ss", which is very necessary.
I have set the worksheet, the file is being imported into, to the same format. My problem is that, during the import of data, Excel (in it's wisdom) decides to automatically transpose the dd and mm numbers (if they meet the natural calendar conditions i.e. 01/09/2006 becomes 09/01/2006, 09/01/2006 becomes 01/09/2006 whilst 21/09/2006 remains the same).
As you can imagine this causes havok with several other functions that I have running off that source data (once imported). I have looked at the code and, whilst I can follow the general gist of it, I am unable to find any reference to format of the data.
View 9 Replies
View Related
Jan 16, 2014
I found this code that import TAB delimited text file. I would like to import space delimited text file instead.
VB:
Option Explicit
Sub ReadTxtFiles()
Const conSpath As String = "C:"
[Code]....
View 6 Replies
View Related
Jun 2, 2009
I have a program in unix that ouputs a text file in .csv form which allows me to import my data into an excel spreadsheet very easily. I am wondering if there is anyway I can add formatting, like to tell excel to make a cell green or something like that.
If it can't be done with .csv, is there any other tool or format available that will accomplish this?
View 9 Replies
View Related
Oct 30, 2008
I have VBA code that imports a text file using a fixed width separator within the code. The code is working just as I need it to work and placing the information/data in the columns that I have specified in the code.
The issue I have is I only want to import certain data that is contained within the text file. It is going to be a little hard to explain, so I have attached a sample of the text file with dummy data to better explain. The file is broken up into different segments. Each segment is identified by a “Base Number” in column A of the text file (once it has been converted into an Excel file).
For my example, I only want to import data for Base Number 38451. The information for this segment is easy enough to identify when the data starts and when the data ends. As in this example, the first occurrence of 38451 begins at row 257. Once the first instance of this number is identified, the first row of data that I require is always two rows after.
I think the coding should go something like this, but I just can’t figure out how to put it into my
If cell in column A = 38451 then
- start importing from 2 rows down
- continue to import until next row in column C is not = date
If row in column C = blank then
- search in column A until cell = 38451
If cell in column A = 38451 then
- start importing from 1 row down
- continue to import until next row in column C is not = date
Else
- stop import
I have included two files. (1) the text file with the data (2) the Excel file. There are two tabs in the Excel file “ReconSheet” (contains the data that is imported from the text file) and “Desired Result” (this is how I want the end product to look).
View 5 Replies
View Related
May 4, 2009
am in a time crunch to write VBA code(not use the macro recorder) to do the following:
Input data from a tab delimited Text file into a pre-formatted sheet.
Each column of the text file is as follows (product code, buy/sell, quantity, price, date) Example row below.
YM Buy 50 12800 1/2/2008
Is there code I can use to do this? I need each individual piece of data to import into it's own cell while keeping the Row/column alignment of the original text document.
View 9 Replies
View Related
Jul 5, 2007
I am importing a text file, Comma Seperated, small sample below....
View 9 Replies
View Related
Dec 15, 2011
I run reports that tell me when an individual is supposed to be in the office and when they actually log in, but this is a manual process where I have to go through several hundred people each morning and check. I have created a macro that pulls in their time in and out and makes there name appear as Last, First.
I run a seperate report that creates a schedule with headers and other information that is useless in this process. I have attached a dummy file and get this down to the last, first name and then the times in and such with no headers? I am also trying to keep the total number of people at the bottom in it's own cell.
I am at a loss as the file uses multiple spaces and not ,'s or ;'s etc.
FILE:
From: 12/14/11 Data TotalView 12/14/11
To: 12/14/11 Company ABC 13:45
Daily Start/Stop Unit Name RED
[Code].....
View 2 Replies
View Related
May 24, 2006
Need Macro where I can import a text file saved on my computer into a new sheet named yesterdays or todays date in format "ddmmyy" and then the sheet gets hidden.
View 9 Replies
View Related
Jun 6, 2007
I am having problems choosing a format for the column in my spreadsheet that contains my account codes. This is especially a problem when the code starts with an '=' sign and is followed by a number or has a '£' sign followed by a number.
I receive the file in a .txt format which I guess if I get it that way I would not have a problem but as I need to work on the file in excel before uploading it I experience problems. For instance when I open the file the codes that begin with '=' + a letter for instance =Y just comes up as '# name?' and only when I click in the cell can I see that it is =Y. Also the code '=1' just comes up as '1' as does '£1' - now this causes problems as for a start I need to do Vlookups on the account code but now instead of three distinct codes I have 3 1's.
The only way that I have discovered how to solve this is to click into each cell and add a ' before the text. (this changes the format to text - right??) But obviously this is very time consuming - is their a quicker way to change these cells. I can't just right click and format cells - text. This does not work?
View 5 Replies
View Related
Dec 1, 2012
This is the text file: Video.txt. I import it using the following settings: "Delimited" as Original data type and "Comma" as Delimiters, with all the other settings left to default. Everything is imported into a single row. It is supposed to be a table, with Stk_No, Title, Certificate, up to In_Stk as column titles; then, all the rest should come below the column titles as rows (they seem to be separated by 5 commas). Am I missing a setting or there is a problem with the text file?
View 2 Replies
View Related
Sep 1, 2006
When opening a CSV file in Excel, it seems Excel makes an "intelligent" attempt at interpreting the data into a data type.
This causes a text field containing 7300070E-4 to be interpreted as 7.30E+0
View 9 Replies
View Related
Jul 20, 2007
I am having a problem with the correct coding needed for a qotation mark
i wish to place a quotation mark around some text with coding
example "TEST" by using the code below this appears fine and looks fine when i save the file, however when i open that file in a .txt file i see """TEST"""
This is the coding i am using and can see it may be where the problem lies
ActiveSheet. Range("C4").Value = """" & Sheets("PRODUCTS").Range("Y1").Value & """"
to correct it i have tried this
ActiveSheet.Range("C4").Value = " & Sheets("PRODUCTS").Range("Y1").Value & "
View 9 Replies
View Related
Sep 19, 2007
I am trying to create a Karaoke Song List in excel, which would show four columns on each page with Artist, Track, Artist, Track. I am importing a text file to do this. The problem I have is that I can import the file so that it puts Artist and Track going down, however, it would then need to go back to the top of the page to fill in the right hand side of the current page. Is there any code that retrieves the current print page number of the current cell (so that I can initiate the code to go to the top right of the current page and continue importing)? Or is there a better way of doing this?
View 3 Replies
View Related
Jun 5, 2008
i cant do this from importing the data, so instead i have to try and fix it with code. I get a sheet of data from an external source that removes the 0's in the front of the number. Its only a 4 digit number so 21 would be 0021. Now i have been able to trap the data i think i would need. i created a =len() statement to tell me how many numbers each cell has. here is the code i think how it would work.. i just need a little help with filling in the blanks. I would assume its something to the lines of " 00+string value if it was 2 numbers needed.
B2 has the Len values (4,3,2,1 etc) and A1 is the original string that has the values.
So i want the code to add 1 2 or 3 zeros to the front of the number based on the len value.
Range("B2").Select
While ActiveCell.Value <> ""
ActiveCell.Offset(0, 0).Select
Select Case ActiveCell.Value
Case Is = "3"
ActiveCell.Offset(-1, 0).Select
ActiveCell.Offset(1, 1).Select
Case Is = "2"
ActiveCell.Offset(-1, 0).Select
ActiveCell.Offset(1, 1).Select......................
View 2 Replies
View Related
Apr 11, 2012
I wanted to see if there is a VBA code to do the following :
a) Select a TabText Delimited file based on a criteria
b) Import the Selected Data to Excel
I have the vba code where I can open the tab text delimited file in excel, use a selection criteria and then copy the data into excel. But I am having problems with the case where the Tab Text Delimited file exceeds the row limit that excel currently has and wanted to see if the data import can be done without opening the text file into excel at all.
Here is my current query :
Sub TEST()
' TEST Macro
Workbooks.OpenText Filename:="E:Testdata.txt"
ActiveSheet.Range("$A$1:$B$1048576").AutoFilter Field:=1, Criteria1:="1234"
Range(Selection, Selection.End(xlToRight)).Select
[Code] .......
View 3 Replies
View Related
Jan 30, 2013
code to import a tab delimited text file with about 3 million rows so that it creates a new tab every time it hits the 1 million row limit?
View 3 Replies
View Related
Apr 11, 2007
I am trying to import a text file into a textbox on a form. It is to help the user to select the body of an email and the signiture.
View 2 Replies
View Related
Aug 13, 2013
Got a slight problem; I am making a "worker-plan", where you should be able to write a name on one file and have it updated (removed) from the equivalent columns on another file automatically. Here's an example with two separate projects:
Project 1 before and after changes:
Attachment 257366
Attachment 257367
Project 2 before and after changes:
Attachment 257368
Attachment 257369
You can see here how I intended it to work. When one worker is moved from Project 1 to Project 2, that worker should also be removed from those weeks in Project 1. The previous worker from Project 2 should also be removed from those weeks (in Project 2).
Are there any formulas that can make this work automatically? All week numbers will belong to the same columns in all files.
Edit: There are 30 files that should be syncronized, not just two.. I could also gather all files into one file with sheets, instead of having seperate files.
View 2 Replies
View Related
Aug 7, 2007
I am using the following code to browse to a CSV file and import it into my current workbook. How can I “capture” the name of the text file (myFile) for future use?
myFile = Application.GetOpenFilename("All Files,*.csv")
If myFile = False Then
Exit Sub
End If
' Open file
With ActiveSheet.QueryTables.Add(Connection:="TEXT;" & myFile, Destination:=Range("A1"))
.Name = "DATA"
.FieldNames = True...............
View 9 Replies
View Related
May 30, 2007
I want macro which export each excel column to new text file. The data in excel file is number. The column has only 5 rows that means each new text file should contain five lines of one column. It looks simple but couldn't manage to do macro for it. I have very big data set in one excel file, and have to be splitted into text files. The file name in new text files can be any kind as long as it can be in some sort of order for each export.
View 2 Replies
View Related
Jun 3, 2009
I am importing data from a csv file into another program. For some reason this particular cell is causing everything past it in the same row to be thrown off. It is moving bits and pieces to the next column, then the next, etc....all in the same row though.
Can you see anything in this data that would cause issues in a csv file when importing. The data in this cell is html code for an ecommerce item description.
View 3 Replies
View Related
Aug 8, 2006
How can I limit the number of lines when importing a file? Limit the import
to the first 53 lines of a file that has 50,000+ lines.
Want to import the first "XX" set of lines, then I want to skip a set of
lines, then continue to import the rest of the lines. The second import needs
to be inserted 2 or 3 lines down from the first import.
There is the function:
Workbooks.OpenText Filename:=
But it only has a StartRow and can not specify the "EndRow". Also can not
specify where to start in the worksheet, i.e. Cell A5
View 10 Replies
View Related
Jun 13, 2007
I have made a macro to import the a excel file into a new file after truncating few initial rows. Here is the code for it:
Sub Import()
Dim Prompt1, Prompt2, Prompt3, myDir, myFile, mySheet As String
Dim ClCnt As Long 'column counter
Prompt1 = "Enter the location of input file:"
myDir = InputBox(Prompt1)
Prompt2 = "Enter filename:"
myFile = InputBox(Prompt2)
Prompt3 = "Enter sheetname:"
mySheet = InputBox(Prompt3)
With Workbooks.Open(myDir & myFile).Sheets(mySheet)
ClCnt = .Range("A33:CB33").SpecialCells(xlConstants).Count ' Count the number of columns present..................
View 5 Replies
View Related
Mar 28, 2007
Here's what I have.. (on a much smaller scale)
http://www.jmetenterprises.com/produ...pics/excel.jpg
(notice how the lines that match are now even.)
[Edited by admin~ *Link* to large images, don't display them]
View 9 Replies
View Related
May 27, 2014
I have a multilevel XML file. Attached my1.zip (XML files cannot be uploaded as is, hence I had to zip it). When I import the XML into excel, it creates multiple columns for the multilevel data. However, I need the multilevel data as additional rows. I have attached another excel file sample.xlsx which shows how excel imports the XML and how I actually need the data to be.
Screen shot attached for your quick reference sample.xlsx.jpg
View 1 Replies
View Related