NoCode and AI
Excel and VBA

ChatGPT for Oil and Gas - Part 2: Data and VBA

Alan Mourgues
February 15, 2024

In Part 1 (here), we explored all the text-related capabilities of the ChatGPT language model, including text generation, proofreading, translation, and summarization.

Today, we're building upon that base-layer capability and cranking it up a notch. The following examples will clearly demonstrate where the real power of this tool lies!

Prompt: 

as a reservoir engineer, your task is to use the exponential decline formula to generate a synthetic production profile for a gas field. initial rate is 10 MMscfd and decline rate is 2% per annum. Provide your output in a table with year and rate, for only the first 10 years

Output:

The reply first presents the exponential decline formula, outlines its input parameters and units, and then proceeds to create the table, exactly as requested:

Let’s assume now that we already have a certain production profile in an Excel sheet, like so:

What you can do is create a screenshot of the table and the chart, and paste it directly into the ChatGPT interface, then prompt away:

Prompt:

this is a historical gas production profile. can you forecast production based on that trend until year 15?

Sometimes, depending on the image quality, ChatGPT may struggle with reading the data and making calculations and inferences from it. You just need to keep probing and providing guidance to steer it towards the desired destination.

Output:

Here’s the response which includes a chart and a table with the projected production.

Think about this for a second: we didn’t process any data, we didn’t provide a database or a table with numbers. All we did was paste an image, and it was smart enough to recognize the image, digitize the data, fit a regression trend, and use that trend to extrapolate the data… all from a screenshot!

How about, instead of asking ChatGPT to create a table with an exponential-decline production profile, we ask it to generate a piece of VBA code that can create such a table inside Excel, with user-defined inputs for the initial rate and the decline rate?

This is what it looks like: imagine we have a simple table with two values; the Initial rate in cell B1 in MMscfd, and the decline rate in cell B2:

Prompt:

Generate a VBA code snippet to generate a production profile in column B using the exponential decline formula. Initial rate is in cell B1 in MMscfd, and decline rate is in cell B2. Put the headers “Year” and “Rate MMscfd” in cells A4 and B4 and write the profile for 10 years

Output:

Unlike the previous issue, I cannot link you to the actual ChatGPT conversation because sharing chats with images is not yet supported by OpenAI. Instead, you can view a short clip demonstrating how the VBA code is generated, pasted into the Excel VBA editor, and run, in this LinkedIn post, here.

Once the code is implemented in VBA, you can edit the input parameters in your table and rerun the code to update both the table and the chart.

Of course, you might argue that there is no need for code in this case since the decline formula is quite simple, and it's more efficient to have the chart linked to a table built from formulas referencing the inputs. However, the point is to demonstrate how effortlessly one can create code without needing much knowledge of VBA at all!

Let’s now rebuild the production table, this time from live formulas. What we want to do is add sliders or scroll bars so that the user can drag them to change the inputs and see how the table and chart dynamically update. Don’t know how to do it? Not to worry, let's ask ChatGPT for instructions.

Prompt: 

give me instructions on how to generate a slider in excel to change the value of cell B1 between 1 and 100

Output:

This is the reply we received, complete with a step-by-step set of instructions:

Once you follow these instructions, you'll end up with something like this:

Pretty neat, isn't it?

Let’s leave it here for now. In the next installment, we'll move onto Python and data analytics to continue being blown away by what ChatGPT can do. Stay tuned.

---

PS: Everything I’m sharing through this series was demonstrated on-screen during a webinar I gave on November 16, 2023. Watch it here:

More Tools

Explore a curated collection of valuable resources in our Store, both free and paid, all designed to help you upskill.

Alan Mourgues is a Petroleum Reservoir Engineering Consultant with 25 years of international experience. He is the founder of CrowdField — the go-to hub for Oil & Gas subsurface professionals to upskill, freelance, and monetize their expertise. CrowdField brings together a global community through: i) Freelance marketplace for niche talent and task-based solutions; ii) Digital Store & Vault of engineering tools, workflows, and resources; iii) AI Hub showcasing startups, workflows, and use cases; iv) Learning resources including webinars, blogs, and curated datasets. Alan’s mission is to empower professionals to turn knowledge into income and future-proof their careers as the energy transition unfolds.

Featured...

All blog posts