Hi !
I have userform whit a combobox and a commandbutton.
The Combobox is populated whit the textfiles in "C:\Users\Petter\Desktop\test"
what i want to do is:
1. Pick a textfile in the combobox.
2. Click commandbutton.
3. Read last entry in picked textfile in combobox (From lastline in reverse to first free line)
If the textfile looks like this:
aaaa 11111 25622
bbbb 22222 254155
cccc 33333 356998
dddd 44444 532256
aaaa 11111 522546
bbbb 22222 154123
cccc 33333 44512
dddd 55555 11255
(2)
aaaa 11111 5245454
bbbb 22245 556t565
cccc 33333 4454545
dddd 55555 4545454 (1)
4. I want it to import lastline of text (1) to first free line of text (2) to sheet2:
This part:
aaaa 11111 5245454
bbbb 22245 556t565
cccc 33333 4454545
dddd 55555 4545454
5. If its possible to separe every space into a new column like:
ColA ColB ColC
aaaa 11111 5245454
bbbb 22245 556t565
cccc 33333 4454545
dddd 55555 4545454
Code i have so far:
Option Explicit
Private Sub CommandButton1_Click()
End Sub
Private Sub UserForm_Initialize()
'Files in folder listed in Listbox1
Dim FSO As Object, fld As Object, Fil As Object
Dim SubFolderName As String
Dim i As Integer
Set FSO = CreateObject("Scripting.FileSystemObject")
Me.ComboBox1.Clear 'clear previous entries
SubFolderName = "C:\Users\Petter\Desktop\test"
Set fld = FSO.GetFolder(SubFolderName)
For Each Fil In fld.Files
i = i + 1
Me.ComboBox1.AddItem Trim(Replace(Mid(Fil.Name, 16), "Sales.txt", ""))
Next Fil
End Sub
Best regards
Petter
Bookmarks