Hi,
I currently have the following VBA code that imports data from a Dbf file into an Excel spreadsheet but even though it clears the sheet before i run it if i run if twice it "inserts" cells shift the remaining cells to the right
Any ideas of how to set the code to overate existing cells would be great
Sub DataQuery()
'
'
Application.ScreenUpdating = False
Dim Mailbox As String
Dim create As Boolean
Dim sConn As String
Dim sSql As String
Dim oQt As QueryTable
create = True
Dim qt As QueryTable
Dim WSh As Worksheet
For Each WSh In ThisWorkbook.Worksheets
For Each qt In WSh.QueryTables
qt.Delete
Next qt
Next WSh
Mailbox = ActiveWorkbook.Path
Sheets("Info").Visible = True
ActiveWorkbook.Sheets("Info").Select
ActiveWorkbook.Sheets("Info").Cells.ClearContents
If create Then
' Allow Data
sConn = "ODBC;CollatingSequence=ASCII;DBQ=C:\TEMP;DefaultDir=C:\TEMP;Deleted=1;Driver={Microsoft dBase Driver (*.dbf)};DriverId=533;FIL=dBase;"
sSql = "SELECT DESC, RETAIL FROM """ & Mailbox & """\ALLOW.DBF ALLOW WHERE(ALLOW.DESC='PIPECLEANING')"
Set oQt = ActiveSheet.QueryTables.Add(Connection:=sConn, Destination:=Range("k1"), Sql:=sSql)
oQt.AdjustColumnWidth = False
oQt.PreserveFormatting = True
oQt.Refresh
Application.ScreenUpdating = True
End If 'Remove if Stacking Query And add to end.
End Sub
Thanks in advance
Bookmarks