Neglect empty cells while refreshing
        Posted  
        
            by 
                Ashok Vardhan
            
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Ashok Vardhan
        
        
        
        Published on 2014-06-12T14:45:16Z
        Indexed on 
            2014/06/12
            15:24 UTC
        
        
        Read the original article
        Hit count: 366
        
I have an excel macro which refreshes the worksheet.
However, if the file (in .csv format) with which the worksheet is being refreshed has empty cells, it's shifting the data from other columns and placing the data in wrong columns.
However,if I manually refresh the sheet, it's working fine. I don't know how I can fix this.
I just want my whole .csv file including empty cells to appear as it is in the worksheet.
Any suggestions would be greatly helpful.
The following is the Macro code.
 With Worksheets("RawData1").QueryTables(1)
    .TextFilePromptOnRefresh = False
    .RefreshStyle = xlinsertdelete
    .Connection = Application.Substitute(.Connection, CurrPath, NewPath)
    .Refresh
 End With
 // We can assume that we have CurrPath and NewPath properly
© Stack Overflow or respective owner