Excel

Automating Google Sheets Downloads to Excel: A Simple PHP Script

In the digital age, managing data efficiently is crucial. Google Sheets, a widely used tool for collaborative data management, sometimes needs to be converted into different formats for further processing. One common requirement is to download a publicly shared Google Sheet as an XLSX file, which can then be used in Excel for advanced data analysis. Here’s a handy PHP script that automates this process.

Why Automate Google Sheets Downloads?

Downloading Google Sheets manually can be tedious, especially if the data is updated frequently. Automating the download process ensures that you always have the latest data in your desired format without repetitive manual effort. Additionally, the XLSX format is compatible with Excel’s powerful features like Power Query, making it easier to transform and analyze data. …

VBA code to refresh an Excel table generated by a power query

Disclaimer: I’m not good at Excel VBA. That’s why I take advantage of ChatGPT to generate the code for me.

The requirements

Here are my requirements:

  1. When I hit the button, refresh the table called AgingTable in the Aging sheet
  2. The AgingTable  is connected to a Power Query called the same name: AgingTable
  3. Since the AgingTable query is a big table and runs several transformation, it may take a while for the query to finish
  4. However, before proceeding to the next script in the VBA I want it to wait for the query to complete

How to do Lookup in Excel and Power Query

Lookup in regular Excel function

The XLOOKUP function has been available to Office 365 and Excel 2021. For compatibility purposes with my workbook’s potential users, I shy away from using this function. Instead, I use the combination of INDEX and MATCH.

Why not VLOOKUP?

I’m not sure if there are any hardware efficiency benefit from using INDEX and MATCH over VLOOKUP or HLOOKUP. But I use INDEX and MATCH primarily for two reasons:

  1. Ability to return the value of the column to the left of your lookup array (left-most column of the table array)
  2. Never worry about adding a column between the returned column and the lookup array. Remember, you indicate the column index number being the returned column from your table array? What if you’ve not touched your file for a long time, return to it and inserting a column in a table, forgetting that you’ve used that table as a table array as a lookup somewhere in your worksheet? You’ll certainly break your VLOOKUP formula.

How to use these formulas

Sorry, but you have to look somewhere else for the usage of these formulas.

Lookup in Power Query

Power Query Lookup Sample File

To better demonstrate the functions, it’s better if we refer to a sample file:

Scroll to Top