{"id":14070701,"url":"https://github.com/cavo789/vba_excel_dataquery_update","last_synced_at":"2026-03-17T21:04:06.187Z","repository":{"id":101354657,"uuid":"378254380","full_name":"cavo789/vba_excel_dataquery_update","owner":"cavo789","description":"Small demo on how to run a UPDATE query on a worksheet","archived":false,"fork":false,"pushed_at":"2021-06-19T07:49:58.000Z","size":142,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-31T21:44:12.175Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"VBA","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cavo789.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-06-18T20:05:51.000Z","updated_at":"2025-10-06T09:36:04.000Z","dependencies_parsed_at":null,"dependency_job_id":"b620bf3f-5980-434a-aa6d-ff62525d48fe","html_url":"https://github.com/cavo789/vba_excel_dataquery_update","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/cavo789/vba_excel_dataquery_update","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cavo789%2Fvba_excel_dataquery_update","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cavo789%2Fvba_excel_dataquery_update/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cavo789%2Fvba_excel_dataquery_update/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cavo789%2Fvba_excel_dataquery_update/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cavo789","download_url":"https://codeload.github.com/cavo789/vba_excel_dataquery_update/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cavo789%2Fvba_excel_dataquery_update/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30631428,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-17T17:32:55.572Z","status":"ssl_error","status_checked_at":"2026-03-17T17:32:38.732Z","response_time":56,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-13T07:08:02.961Z","updated_at":"2026-03-17T21:04:06.152Z","avatar_url":"https://github.com/cavo789.png","language":"VBA","funding_links":[],"categories":["VBA"],"sub_categories":[],"readme":"# Running UPDATE statements on a worksheet\n\n![Banner](./banner.svg)\nSmall demo on how to run a UPDATE query on a worksheet\n\n## Description\n\nThis is a small proof of concept but a working one.\n\nThe need is the following: you have an Excel worksheet that contains a large number of columns and, based on rules, you want to complete a column e.g. a status.\n\nYou can do it with a `IF` formula when you've only one *rule* but what if you've multiple conditions?\n\n![Worksheet](images/worksheet.png)\n\nWhat is a rule?  In fact, we can write a rule as an `UPDATE` query:\n\n```sql\nUPDATE TheSheet SET StatusColumn=\"...\" WHERE FirstColumn=xxx and SecondColumn=yyy and ThirdColumn=zzz`\n```\n\nIn this example, we can write an `IF` formula... Easy.\n\nBut consider 250 rules? The `IF` formula will be just impossible to write and to maintain.\n\nLet's think outside the box.\n\nExcel, since years, allows to access to the spreadsheet just like if it is a database table.\n\nWhy not using a `rules` table that will define all the conditions (the 250 rules in my example will be 250 rows in the `rules` table). Then, with a small VBA code, process the first rule, convert it as an `UPDATE` statement, run it against the data worksheet and process the second rule, until the last one.\n\nSo, at the end, we can just put a button on the sheet, click on it and ... tadaaaa:\n\n![Demo](./images/demo.gif)\n\nBelow the `rules` sheet:\n\n![The rules sheet](./images/rules.png)\n\nThe VBA is really simple, it's just a proof of concept, and can be improved easily to support OR statement, start / end with conditions and many more.\n\nDownload the [Dataquery_Update_sample.xlsm](Dataquery_Update_sample.xlsm) file to get the example or just see the code in the `src` folder of this repository.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcavo789%2Fvba_excel_dataquery_update","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcavo789%2Fvba_excel_dataquery_update","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcavo789%2Fvba_excel_dataquery_update/lists"}