Excel connected to SQL Server - every new import causes REF! errors and issues with formulas

Nola111

Board Regular
Joined
Aug 28, 2013
Messages
119
Excel 2016 - I have an Excel file that imports a table from SQL Server via a connection created with the Data->Get Data->From Database->From Sql Server Database.

When I built the file, I imported the latest information from the SQL table, which created a table automatically in Excel, and then went to work creating all the formulas I needed to get the summary information I needed.

All worked well - then I did a second import from the same connection with a new date range, a smaller one, so fewer rows were imported.

The issue is that, upon import, it appears that rather than clearing the data from the first import and then creating the new table, it actually deletes the rows that are no longer being used. This in turn causes a slew of REF errors and re-shuffling of ranges within all my formulas.

Does anyone know a way to work around this? I'll give two examples:

1. In all of my formulas, I reference the pertinent table range as A2:A750000. 750,000 rows is the max rows we ever expect. I don't use the range A:A for two reasons: I don't want A1 included in the range, and doing so greatly impacts performance. So when the new data is imported, that A2:A750000 range gets jacked up in all the formulas that contain it.

2. The more critical example - I have an IF formula that looks at each cell in column A in the table and returns a number depending on the condition. The aforementioned new import of data throws REF errors for all rows that were populated before, and then are no longer populated with the new refresh. Again, because it appears the new import deletes rows rather than clearing data.

Any help with this would be greatly appreciated.
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Are the External data properties for the resulting Table set to overwrite, or are they still at the default Insert/Delete setting?
 
Upvote 0
Are the External data properties for the resulting Table set to overwrite, or are they still at the default Insert/Delete setting?

Hi Rory, this is a very good question. Where would I find this information? I've right-clicked on the connection and clicked Edit, which brings me to a window called Query Editor with many options.
 
Upvote 0
Ah I've found it - a window called External Data Properties.

It's set to "Insert Cells for new data, delete unused cells"

It would appear that I need "Overwrite existing cells with new data, clear unused cells"

I think this should be my answer!!
 
Upvote 0
Glad to help. :biggrin:
 
Upvote 0

Forum statistics

Threads
1,213,528
Messages
6,114,154
Members
448,553
Latest member
slaytonpa

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