displaying 'Getting External data' instead of the resultset in the sheet after running macro

Pushpa K

New Member
Joined
Feb 23, 2016
Messages
1
There is data in Employee_information sheet and Income_tax sheet and using vba code I am retrieving the data in the third sheet 'Sheet3' based on the condition that Employee_information.emp_no=Income_tax.emp_no.Macro running correctly with no errors but data is not displaying in the sheet3.Displaying 'Getting External data' in the A1 column but no data found.This is my code.Please someone help me asap.
Code:
  Sub Macro3() b = ThisWorkbook.Name currentDir = ThisWorkbook.Path  Workbooks(b).Sheets("Sheet3").Activate  Application.ScreenUpdating = False   On Error Resume Next Worksheets("Sheet3").Range("Table_Query_from_Excel_Files[#All]").Select Selection.Clear           With ActiveSheet.ListObjects.Add(SourceType:=0, Source:=Array(Array( _         "ODBC;DSN=Excel Files;DBQ=" & currentDir & "\" & b & ";DefaultDir=" & currentDir & ";DriverId=1046;MaxBufferS" _         ), Array("ize=2048;PageTimeout=5;")), Destination:=Range("$A$1")).QueryTable         '.CommandType = 0         .CommandText = Array( _         "SELECT `Employee_Information$`.`Employee Number`, `Employee_Information$`.`Employee Name`, `Employee_Information$`.`Grade Code`, `Employee_Information$`.`Designation Code`, `Income_Tax$`.`Total Gross`" _         , _         ", `Income_Tax$`.`Total Basic`, `Income_Tax$`.`Total DA`, `Income_Tax$`.`Total HRA`" & Chr(13) & "" & Chr(10) & "FROM `" & currentDir & "\" & b & "`.`Employee_Information$` `Employee_Information$`, `" & currentDir & "\" & b & "`.`Income_Tax$` `Income_Tax$`" & Chr(13) & "" & Chr(10) & "WHERE `Employee_Information$`.`Employee Number` = `Income_Tax$`.`Employee Number`" _         )         .RowNumbers = False         .FillAdjacentFormulas = False         .PreserveFormatting = True         .RefreshOnFileOpen = False         .BackgroundQuery = True         .RefreshStyle = xlInsertDeleteCells         .SavePassword = False         .SaveData = True         .AdjustColumnWidth = True         .RefreshPeriod = 0         .PreserveColumnInfo = True         .ListObject.DisplayName = "Table_Query_from_Excel_Files"         .Refresh BackgroundQuery:=False     End With End Sub
Thanks in Advance Pushpa K
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.

Forum statistics

Threads
1,216,025
Messages
6,128,352
Members
449,443
Latest member
Chrissy_M

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top