Solved

Excel query import, shifting data to the right

Posted on 2014-11-06
1
68 Views
Last Modified: 2014-11-11
Hi Experts

I have some long standing code that imports data from a Web source, I've been using it for ages and it works without issue. However I've started to use it with an existing workbook and when the data imports it shifts all the cells to the right of the worksheet, I dont want it to do this and I just want to simply over write the existing data. Anyone any ideas?

With ActiveSheet.QueryTables.Add(Connection:= _
        "TEXT;" & strReport & "", _
        Destination:=Range("A2"))
        .Name = "CashForecastABI"
        .FieldNames = True
        .RowNumbers = False
        .FillAdjacentFormulas = False
        .PreserveFormatting = True
        .RefreshOnFileOpen = False
        '.RefreshStyle =  xlInsertDeleteCells
        .AdjustColumnWidth = True
        .RefreshPeriod = 0
        .TextFilePromptOnRefresh = False
        .TextFilePlatform = 1252
        .TextFileStartRow = 1
        .TextFileParseType = xlDelimited
        .TextFileTextQualifier = xlTextQualifierDoubleQuote
        .TextFileConsecutiveDelimiter = False
        .TextFileTabDelimiter = False
        .TextFileSemicolonDelimiter = False
        .TextFileCommaDelimiter = True
        .TextFileSpaceDelimiter = False
        .TextFileColumnDataTypes = Array(1)
        .TextFileTrailingMinusNumbers = True
        .Refresh BackgroundQuery:=False
    End With
0
Comment
Question by:MrDavidThorn
1 Comment
 
LVL 27

Accepted Solution

by:
Glenn Ray earned 500 total points
ID: 40426703
I see that you've commented out the .RefreshStyle property.

change that line to
.RefreshStyle xlOverwriteCells


Regards,
-Glenn
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
DBF to ... Converter 5 45
Advice in Xamarin 21 57
Conditional Format - Prevent User entering USA Date formats into Excel 2010 3 24
Auto Adjust Percent rate 5 31
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

861 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now