Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Imported text file to begin from the first empty cell

Hi

I want to import a textfile to excel worksheet. Problem is, that I want the
imported data to begin in the first empty cell in column A. How do I do this?
So far the macro is:

Sub data_import()

With
ActiveSheet.QueryTables.Add(Connection:="TEXT;C:\O pticon\Data\Data.txt" _
, Destination:=Range("A1"))
.Name = "Data"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = False
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 850
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = True
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1, 1, 1, 1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
End Sub

Thanks,
Elina
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 586
Default Imported text file to begin from the first empty cell

Add this line to the top of your code:

' finds first empty cell in Col A, starting from top of sheet
lngLastRow = ActiveSheet.Cells(1, "A").End(xlDown).Row + 1

Then change your destination line:

Destination:=Range("A" & lngLastRow)
--
Cheers,
Ryan


"p11p00" wrote:

Hi

I want to import a textfile to excel worksheet. Problem is, that I want the
imported data to begin in the first empty cell in column A. How do I do this?
So far the macro is:

Sub data_import()

With
ActiveSheet.QueryTables.Add(Connection:="TEXT;C:\O pticon\Data\Data.txt" _
, Destination:=Range("A1"))
.Name = "Data"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = False
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 850
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = True
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1, 1, 1, 1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
End Sub

Thanks,
Elina

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Imported text file to begin from the first empty cell

Thank you RyanH, this works, if I have 2 first rows filled for some reason.
Anyway I can use this.

Cheers,
Elina



"RyanH" kirjoitti:

Add this line to the top of your code:

' finds first empty cell in Col A, starting from top of sheet
lngLastRow = ActiveSheet.Cells(1, "A").End(xlDown).Row + 1

Then change your destination line:

Destination:=Range("A" & lngLastRow)
--
Cheers,
Ryan


"p11p00" wrote:

Hi

I want to import a textfile to excel worksheet. Problem is, that I want the
imported data to begin in the first empty cell in column A. How do I do this?
So far the macro is:

Sub data_import()

With
ActiveSheet.QueryTables.Add(Connection:="TEXT;C:\O pticon\Data\Data.txt" _
, Destination:=Range("A1"))
.Name = "Data"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = False
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 850
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = True
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1, 1, 1, 1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
End Sub

Thanks,
Elina

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 586
Default Imported text file to begin from the first empty cell

If the first two rows always have something in them use this.

lngLastRow = ActiveSheet.Cells(2, "A").End(xlDown).Row + 1

I hope this helps! If so, then click "YES" below.
--
Cheers,
Ryan


"p11p00" wrote:

Thank you RyanH, this works, if I have 2 first rows filled for some reason.
Anyway I can use this.

Cheers,
Elina



"RyanH" kirjoitti:

Add this line to the top of your code:

' finds first empty cell in Col A, starting from top of sheet
lngLastRow = ActiveSheet.Cells(1, "A").End(xlDown).Row + 1

Then change your destination line:

Destination:=Range("A" & lngLastRow)
--
Cheers,
Ryan


"p11p00" wrote:

Hi

I want to import a textfile to excel worksheet. Problem is, that I want the
imported data to begin in the first empty cell in column A. How do I do this?
So far the macro is:

Sub data_import()

With
ActiveSheet.QueryTables.Add(Connection:="TEXT;C:\O pticon\Data\Data.txt" _
, Destination:=Range("A1"))
.Name = "Data"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = False
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 850
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = True
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1, 1, 1, 1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
End Sub

Thanks,
Elina

Reply
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
formatting a text file imported into excel GinaH Excel Worksheet Functions 1 August 6th 09 08:30 PM
can I display the file name of the imported text file in another c John-G Excel Discussion (Misc queries) 0 May 13th 05 03:38 PM
Parsing imported text file with macro... help! scrupul0us[_2_] Excel Programming 0 September 7th 04 10:13 PM
Imported Text File Worksheet Tab Name bob Excel Programming 3 August 13th 04 04:36 PM
if then elseif on text file imported into excel mike windbigler Excel Programming 1 July 26th 04 11:48 AM


All times are GMT +1. The time now is 06:22 AM.

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

About Us

"It's about Microsoft Excel"