PC Review


Reply
Thread Tools Rate Thread

How can I automatically import into next empty row

 
 
Saucer Man
Guest
Posts: n/a
 
      23rd Dec 2008
I have a macro which automatically imports the contents of a .csv file.
However, it imports only into the row which is hardcoded. How do I get the
import to start in Column A of the next empty row? The import should start
in Column A of the next empty row and fill in from there. Here is my
code...

With
ActiveSheet.QueryTables.Add(Connection:="TEXT;c:\UPS_CSV_EXPORT.csv",Destination:=Range("A8"))
.Name = "UPS_CSV_EXPORT"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = False
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 437
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = False
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = True
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With

--
Thanks!


 
Reply With Quote
 
 
 
 
Gord Dibben
Guest
Posts: n/a
 
      23rd Dec 2008
Set rng1 = ActiveSheet.Cells(Rows.Count, 1).End(xlUp) _
.Offset(1, 0)
With
ActiveSheet.QueryTables.Add(Connection:="TEXT;c:\UPS_CSV_EXPORT.csv",Destination:=rng1)


Gord Dibben MS Excel MVP

On Tue, 23 Dec 2008 16:44:12 -0500, "Saucer Man" <(E-Mail Removed)>
wrote:

>I have a macro which automatically imports the contents of a .csv file.
>However, it imports only into the row which is hardcoded. How do I get the
>import to start in Column A of the next empty row? The import should start
>in Column A of the next empty row and fill in from there. Here is my
>code...
>
> With
>ActiveSheet.QueryTables.Add(Connection:="TEXT;c:\UPS_CSV_EXPORT.csv",Destination:=Range("A8"))
> .Name = "UPS_CSV_EXPORT"
> .FieldNames = True
> .RowNumbers = False
> .FillAdjacentFormulas = False
> .PreserveFormatting = True
> .RefreshOnFileOpen = False
> .RefreshStyle = xlInsertDeleteCells
> .SavePassword = False
> .SaveData = True
> .AdjustColumnWidth = False
> .RefreshPeriod = 0
> .TextFilePromptOnRefresh = False
> .TextFilePlatform = 437
> .TextFileStartRow = 1
> .TextFileParseType = xlDelimited
> .TextFileTextQualifier = xlTextQualifierDoubleQuote
> .TextFileConsecutiveDelimiter = False
> .TextFileTabDelimiter = False
> .TextFileSemicolonDelimiter = False
> .TextFileCommaDelimiter = True
> .TextFileSpaceDelimiter = False
> .TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
>1, 1, 1, 1, 1)
> .TextFileTrailingMinusNumbers = True
> .Refresh BackgroundQuery:=False
> End With


 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      23rd Dec 2008
Dim DestCell as range

with activesheet
set destcell = .cells(.rows.count,"A").end(xlup).offset(1,0)
with .QueryTables.Add(Connection:="TEXT;c:\UPS_CSV_EXPORT.csv", _
Destination:=destcell)
.name = .....
...
end with
end with


Saucer Man wrote:
>
> I have a macro which automatically imports the contents of a .csv file.
> However, it imports only into the row which is hardcoded. How do I get the
> import to start in Column A of the next empty row? The import should start
> in Column A of the next empty row and fill in from there. Here is my
> code...
>
> With
> ActiveSheet.QueryTables.Add(Connection:="TEXT;c:\UPS_CSV_EXPORT.csv",Destination:=Range("A8"))
> .Name = "UPS_CSV_EXPORT"
> .FieldNames = True
> .RowNumbers = False
> .FillAdjacentFormulas = False
> .PreserveFormatting = True
> .RefreshOnFileOpen = False
> .RefreshStyle = xlInsertDeleteCells
> .SavePassword = False
> .SaveData = True
> .AdjustColumnWidth = False
> .RefreshPeriod = 0
> .TextFilePromptOnRefresh = False
> .TextFilePlatform = 437
> .TextFileStartRow = 1
> .TextFileParseType = xlDelimited
> .TextFileTextQualifier = xlTextQualifierDoubleQuote
> .TextFileConsecutiveDelimiter = False
> .TextFileTabDelimiter = False
> .TextFileSemicolonDelimiter = False
> .TextFileCommaDelimiter = True
> .TextFileSpaceDelimiter = False
> .TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
> 1, 1, 1, 1, 1)
> .TextFileTrailingMinusNumbers = True
> .Refresh BackgroundQuery:=False
> End With
>
> --
> Thanks!


--

Dave Peterson
 
Reply With Quote
 
JE McGimpsey
Guest
Posts: n/a
 
      23rd Dec 2008
One way:

Dim rDest As Range
Set rDest = Cells(Rows.Count, 1).End(xlUp).Offset(1, 0)

then in your QueryTables.Add call, use

Destination:=rDest


In article <49515bad$0$1546$(E-Mail Removed)>,
"Saucer Man" <(E-Mail Removed)> wrote:

> I have a macro which automatically imports the contents of a .csv file.
> However, it imports only into the row which is hardcoded. How do I get the
> import to start in Column A of the next empty row? The import should start
> in Column A of the next empty row and fill in from there. Here is my
> code...
>
> With
> ActiveSheet.QueryTables.Add(Connection:="TEXT;c:\UPS_CSV_EXPORT.csv",Destinati
> on:=Range("A8"))
> .Name = "UPS_CSV_EXPORT"
> .FieldNames = True
> .RowNumbers = False
> .FillAdjacentFormulas = False
> .PreserveFormatting = True
> .RefreshOnFileOpen = False
> .RefreshStyle = xlInsertDeleteCells
> .SavePassword = False
> .SaveData = True
> .AdjustColumnWidth = False
> .RefreshPeriod = 0
> .TextFilePromptOnRefresh = False
> .TextFilePlatform = 437
> .TextFileStartRow = 1
> .TextFileParseType = xlDelimited
> .TextFileTextQualifier = xlTextQualifierDoubleQuote
> .TextFileConsecutiveDelimiter = False
> .TextFileTabDelimiter = False
> .TextFileSemicolonDelimiter = False
> .TextFileCommaDelimiter = True
> .TextFileSpaceDelimiter = False
> .TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
> 1, 1, 1, 1, 1)
> .TextFileTrailingMinusNumbers = True
> .Refresh BackgroundQuery:=False
> End With

 
Reply With Quote
 
Saucer Man
Guest
Posts: n/a
 
      24th Dec 2008
Thanks for the replies. It works!

"Saucer Man" <(E-Mail Removed)> wrote in message
news:49515bad$0$1546$(E-Mail Removed)...
>I have a macro which automatically imports the contents of a .csv file.
>However, it imports only into the row which is hardcoded. How do I get the
>import to start in Column A of the next empty row? The import should start
>in Column A of the next empty row and fill in from there. Here is my
>code...
>
> With
> ActiveSheet.QueryTables.Add(Connection:="TEXT;c:\UPS_CSV_EXPORT.csv",Destination:=Range("A8"))
> .Name = "UPS_CSV_EXPORT"
> .FieldNames = True
> .RowNumbers = False
> .FillAdjacentFormulas = False
> .PreserveFormatting = True
> .RefreshOnFileOpen = False
> .RefreshStyle = xlInsertDeleteCells
> .SavePassword = False
> .SaveData = True
> .AdjustColumnWidth = False
> .RefreshPeriod = 0
> .TextFilePromptOnRefresh = False
> .TextFilePlatform = 437
> .TextFileStartRow = 1
> .TextFileParseType = xlDelimited
> .TextFileTextQualifier = xlTextQualifierDoubleQuote
> .TextFileConsecutiveDelimiter = False
> .TextFileTabDelimiter = False
> .TextFileSemicolonDelimiter = False
> .TextFileCommaDelimiter = True
> .TextFileSpaceDelimiter = False
> .TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
> 1, 1, 1, 1, 1, 1)
> .TextFileTrailingMinusNumbers = True
> .Refresh BackgroundQuery:=False
> End With
>
> --
> Thanks!
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Empty Folders Automatically Lori Windows Vista Mail 1 9th Feb 2008 07:05 PM
Empty OLK Folder Automatically Karine Rivet Microsoft Outlook 0 22nd Jun 2006 11:12 PM
Automatically selecting the next empty row Alec H Microsoft Excel Misc 2 1st Mar 2006 09:21 AM
Import specs empty? =?Utf-8?B?S291IFZhbmc=?= Microsoft Access External Data 0 30th Nov 2005 08:26 PM
MySQL import empty karen Microsoft Access External Data 0 18th Sep 2003 10:38 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:58 PM.