Importing A Partial Text File
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
ADVERTISEMENT
Jun 18, 2014
I have about 100 text files from which I need to import specific sets of numbers into excel. The part in the file looks like this
Mg24(MR)1917.4198.5
Mg25(MR)250.453.6
Mg26(MR)264.464.2
I need to import the numbers in the 1st row but they need to be transposed. and than of cause I need to do that for the other 99 files I have.
View 14 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
May 20, 2014
This is for Excel 2007,I have two sets of model numbers. One set is the full model numbers of the units we use, and the other is an abbreviated form used to lookup up certificate numbers. I need a way to match these up so I can use one set of search criteria to find out if there is a match. Here is an example of what I need to match with a partial text match:
H,AE35(6,9)36+TD and AE3563636D145C2501AP
H,RE36(6,9)36 and RE36936C145B2505AP
if I could do this with a formula that matches multiple items at the same time (ie; if A & B & C match=true) with the above model number being one of those items (certificate numbers are issued for sets, but the other model numbers are fine).If that's not possible, a one time VBA run to match all of the abbreviations at once would also work. If these items are matched up with a one time VBA, the VBA needs to account for their being more than one match for each abbreviation depending on the size of the unit.
So H,AE35(6,9)36+TD could be matched to:
AE3563636D145C2501AP
AE3563636D175C2501AP
AE3563636D210C2501AP
View 11 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
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
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
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
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 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
Oct 7, 2008
I'm attempting to copy some files into an archive folder in the same main folder. These files appear weekly in a folder that contains numerous other files.
Each of these files has a filename such as:
RAH_MRL_TOP_40_(ddmmyy_TIME)
with time being the time that the report was run.
Every week the filename stays the same but the time and date changes. I was hoping to be able to simply use the "Filecopy" command and specify the source file with a "*" after the main file name. However this does not seem to work.
Is there a simple way to do this? (I dont want more than a few lines of coding really as I will be duplicating it for each file and then changing the file name as needed.
View 9 Replies
View Related
Mar 15, 2007
Cell H1 has a variable string of references for eg
"FI570783AQ3516346EQ3516346FXVB123456"
I want to return the reference beginiing with "FXVA" so it would ignore the rest and only return FXVB123456 - this should always be 10 characters.
Just to add another complication to the mix, there may be 2 "FXVA" references in the string and i want to get both (these can be in the same string so FXVB123456FXEL123456 - but this might not happen regularly.
View 9 Replies
View Related
Nov 21, 2008
I am trying to set a file name as a string to use it as an attachment. The user inputs a number into a textbox. That number is used to locate the file in location. But the file name is different with each file. So im trying to do something like
"C:Desktop*TextBox1*.docx"
Whereas the actual file name is "C:DesktopMCJC RFI 1 MISSING ROOM NUMBERS.docx"
The location "C:Desktop" will always remain the same as will ".docx". I have everything else working just fine.
View 8 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