Have you ever wanted to delete or add columns in a Google Sheet, based on another set of Sheet data?
In this tutorial, we’ll show you how to use Google Apps Script to update your headers based on another sheets values. These sheets values can come from the current Google Sheet workbook or another one. We will also ensure that the data below the headers is migrated along with the new header location.
Source: Google Apps Script: Add and removed Google Sheets columns based on a search array