Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Text File:
- Birmingham
- France
- Isle of White
- Manchester
- New-Castle
- Birmingham France Isle of White Manchester New-Castle
- Row 1
- Birmingham France Isle of White Manchester New-Castle
- Row 2
- London Spain America Sutton Scotland
- Sub Import_All_Text_Files_2007()
- Dim nxt_row As Long
- 'Change Path
- Const strPath As String = "Z:NSUnactioned"
- Dim strExtension As String
- 'Stop Screen Flickering
- Application.ScreenUpdating = False
- ChDir strPath
- 'Change extension
- strExtension = Dir(strPath & "*.txt")
- Do While strExtension <> ""
- 'Sets Row Number for Data to Begin
- nxt_row = Range("A1").End(xlUp).Offset(0, 0).Row
- 'Below is from a recorded macro importing a text file
- FileNum = FreeFile()
- curCol = 1
- Open strPath & strExtension For Input As #FileNum
- While Not EOF(FileNum)
- Line Input #FileNum, DataLine
- ActiveSheet.Cells(nxt_row, curCol) = DataLine
- curCol = curCol + 1
- Wend
- Close #FileNum
- strExtension = Dir
- Loop
- Application.ScreenUpdating = True
- End Sub
- nxt_row = Range("A1").End(xlUp).Offset(0, 0).Row
- nxt_row = Range("A10000").End(xlUp).Offset(1, 0).Row
- if Range("A1").Value = "" then
- nxt_row = 1
- else
- if Range("A2").Value = "" then
- nxt_row = 2
- else
- nxt_row = Range("A1").End(xlDown).Offset(1).Row
- end if
- end if
Add Comment
Please, Sign In to add comment