Adding only new values to a sheet from a recordset

Simebaby

New Member
Joined
Dec 8, 2009
Messages
11
Hi All
I currently have a worksheet containing data grabbed from a SQL database.
When the data is refreshed, I need to add any news values in the recordset to the sheet, but leave any existing ones in place.
I can construct a unique id from 3 columns of the data for comparison.
Currently I'm looping through the recordset, and any rows that aren't already in the sheet are added.
That works but I suspect it's *very* inefficient - is there a tried and tested way to do this?
I'm sure there's something obvious that' I'm missing.
TIA
Si
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
I think you've reached the point where you definitely are using the wrong app. Just my opion - Excel isn't a database even though so many people seem to want to use it like a database. Unless you can just write your data into an expandable Excel table and use the tools "Remove Duplicates" option then I think you're right. The bigger the list gets, the more this will get bogged down as you loop through it.

One other thing that comes to mind is if you can link your sheet to the sql data, you could create an unmatched query that will find records in the sql data that are not in the sheet, then you could use that as the basis of an update query that you'd have to export to your sheet. However, I think you could only "link" the sheet & sql data by using Access as the go-between app. Note that in Access, linked sheets are static and AFAIK cannot be updated since long ago.

You could also move the Excel part of the process to Access, but Access has a significant learning curve and you will struggle if you design tables like spreadsheets, which is what just about every Excel aficionado does.
 
Upvote 0
Solution
I think you've reached the point where you definitely are using the wrong app. Just my opion - Excel isn't a database even though so many people seem to want to use it like a database. Unless you can just write your data into an expandable Excel table and use the tools "Remove Duplicates" option then I think you're right. The bigger the list gets, the more this will get bogged down as you loop through it.

One other thing that comes to mind is if you can link your sheet to the sql data, you could create an unmatched query that will find records in the sql data that are not in the sheet, then you could use that as the basis of an update query that you'd have to export to your sheet. However, I think you could only "link" the sheet & sql data by using Access as the go-between app. Note that in Access, linked sheets are static and AFAIK cannot be updated since long ago.

You could also move the Excel part of the process to Access, but Access has a significant learning curve and you will struggle if you design tables like spreadsheets, which is what just about every Excel aficionado does.
Agreed. As the data is ordered by date and time, I've gone with finding the most recent date / time, and selecting any data *after* that. Not perfect but will most likely suffice for what I need.
The data is already held in SQL so bringing that into access would be just crazy duplication I would think. The problem is the SQL database only holds the last three months of data and I want to keep any historical entries. I might look at using Access as a longer term thing though.
 
Upvote 0
The data is already held in SQL so bringing that into access would be just crazy duplication I would think.
You'd link to it, not import it - unless you wanted to keep records beyond the 3 month window that they are in sql db
 
Upvote 0

Forum statistics

Threads
1,214,951
Messages
6,122,446
Members
449,083
Latest member
Ava19

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