I only need to copy the "DoseNew" value (6.66666e+016) and then put them into an excel sheet.
Also I would like it if I could "User define" a portion of txt file name to open these files. Meaning that I run a program that generates a unique file name but is incremented to the 130 files, however I will be running other unique files in this same directory here is a sample of the .txt file name structure:
The “XX” portion is the same. The “Res_1” is the portion that increments example “Res_2”, “Res_3” and so on to “Res_130”
What I have so far:
Set fd = Application.FileDialog(msoFileDialogFilePicker)
Dim vrtSelectedItem As Variant
Dim fd_gefile As Variant
Dim copercent, thickness, depth, epsilon, dosenew, doseold, co As Variant
Dim temphold As Variant
If icheck = 1 Then
fd_gefile = datafile$
.InitialFileName = Path$
If .Show = -1 Then
For Each vrtSelectedItem In .SelectedItems
temphold = vrtSelectedItem
fd_gefile = temphold
'The user pressed Cancel.
Line Input #1, co
co = Trim(co)
Length = Len(co) - 3
Cells(20, 11) = Val(Right(co, Length))
icheck = 0
Just a little explanation:
Path$ = Cells(11, 2) & "\" & Cells(7, 2) & Cells(110, 11)
This part tells the macro where to look based upon user defined cell instructions
This macro pulls all of the data from the text file, I can delete the other portions to just give me the “DoseNew” value. But my real question is how I can go about modifying this program (Or start over) with a program that can look at 130 files…any help would be great, thanks in advance
is this any help you could find all instances of these textfiles and loop them one at a time,
.LookIn = "H:\EXCEL"
.SearchSubFolders = True
.Filename = "*mytext*.txt"
If .Execute(SortBy:=msoSortByFileName, SortOrder:=msoSortOrderDescending) > 0 Then
MsgBox "There were " & .FoundFiles.Count & " file(s) found."
For I = 1 To .FoundFiles.Count
Cells(I + 1, 1) = (.FoundFiles(I))
MsgBox "There were no files found."