LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Looping Text Import problem

Hi all,

I have a macro that imports text files based on user input. My problem is
that after about 350 imports the data jumps across the page and inserts
itself where it likes!! The code I have is below...

Private Sub CommandButton1_Click()
Dim fName As String
Dim ext As String
Dim dest As Integer
Dim fileCounter As Integer
Dim endFileCounter As Integer

fileCounter = UserForm1.StartNumber.Value
endFileCounter = UserForm1.EndNumber.Value
ext = ".C09"
dest = 1

Do While fileCounter <= endFileCounter
fName = "U:\Scandat\DownloadedWipLabour\L000" & fileCounter & ext
If fileCheck(fName) Then
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;" & fName, Destination:=Range("$A$" & dest _
))
.Name = "L000" & fileCounter
.FieldNames = False
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = xlWindows
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = True
.TextFileTabDelimiter = False
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileOtherDelimiter = "|"
.TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1)
.Refresh BackgroundQuery:=False
End With
Else
End If
fileCounter = fileCounter + 1

If markBlanks("A" & dest) Then
Range("A" & dest).Value = "BLANK FILE " & fName
Else
End If

dest = dest + 1
Loop

'Application.ScreenUpdating = True

End Sub

Public Function fileCheck(fileName As String) As Boolean
fileCheck = (Dir(fileName) "")
End Function

Public Function markBlanks(cellPosition As String) As Boolean
markBlanks = Range(cellPosition).Value = ""
End Function

Each file that's imported is single line text.

Is there any reason for the data jumping across the page?

NB: It does this in XL2000 and XL2003
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Import External Text Data and Refreshing Problem Douglas Excel Worksheet Functions 0 August 20th 07 09:30 AM
import excel to Access has a problem with text field ABCBAC Excel Worksheet Functions 0 November 11th 06 08:09 AM
Text Import Wizard: File Origin Problem Baldbloke Excel Discussion (Misc queries) 0 March 29th 06 02:51 PM
Import text file problem [email protected] Excel Programming 0 November 15th 05 04:41 PM
Text Import & Current Range problem..... Jim[_35_] Excel Programming 1 November 27th 03 03:10 AM


All times are GMT +1. The time now is 08:57 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"