PDA

View Full Version : [SOLVED] Row count +1 on data import



M-Help
01-23-2014, 07:40 AM
Hello,

I'm trying to import data but I need the row count to be +1.

I tried multiple things without luck.

example of what I need;
"TEXT;C:\temp\data.txt", Destination:=Range("A" & Rows.Count + 1).End(xlUp).Offset(1, 0))

Any help will be appreciated.

Thank you,



Sub Import_Data()
'
' Import_Data Macro
'


'Insert row above active cell


With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;C:\temp\data.txt", Destination:=Range("A" & Rows.Count).End(xlUp).Offset(1, 0))
.Name = "Device Uptime"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 850
.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)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With

End Sub

Bob Phillips
01-23-2014, 08:08 AM
Maybe try


"TEXT;C:\temp\data.txt", Destination:=Range("A" & Activesheet.Usedrange.Rows.Count + 1).End(xlUp).Offset(1, 0))

M-Help
01-23-2014, 08:31 AM
Hello xld,

The text import, but same result, no empty row between imports.

Thank you,

mancubus
01-23-2014, 08:38 AM
make it +2... or offset 2 rows.
Range("A" & Rows.Count).End(xlUp).Offset(2)

M-Help
01-23-2014, 08:41 AM
That's work exactly as expected, case close. thank you very much.