Page 1
Page 1
Started By
Message

Grok is a Beast...

Posted on 7/17/25 at 3:37 pm
Posted by Clyde Tipton
Planet Earth
Member since Dec 2007
40461 posts
Posted on 7/17/25 at 3:37 pm
I never really knew what to use AI for and it hit me last night while I was dreading an upcoming O&G production update...

What used to take a lot of time and formatting now takes seconds...

I got this dude writing macros like a mad man to load O&G production data for multiple wells.

quote:

I just noticed something, I need an column for "previous date" in column B, do not worry about filling it with data, as discussed earlier I can just use the excel EDATE formula to calculate those start dates based off the given report data in the workbook.

Got it! You want to modify the ConsolidateProductionData macro to add a "Previous Date" column in column B of the "ConsolidatedData" sheet, shifting the existing "Date" column to column C, "Oil Production" to column D, and "Gas Production" to column E. You’ll handle populating the "Previous Date" column using Excel’s EDATE formula later, so the macro just needs to include the header for "Previous Date" in column B and copy the data as before (starting from row 9, with sheet name in column A, raw dates in column C, etc.).Here’s the updated macro:vba

Sub ConsolidateProductionData()
Dim wb As Workbook
Dim ws As Worksheet
Dim wsConsolidated As Worksheet
Dim rowOutput As Long
Dim lastRow As Long
Dim i As Long

' Set reference to the active workbook
Set wb = ThisWorkbook

' Check if ConsolidatedData sheet exists, delete if it does
On Error Resume Next
Set wsConsolidated = wb.Sheets("ConsolidatedData")
If Not wsConsolidated Is Nothing Then
Application.DisplayAlerts = False
wsConsolidated.Delete
Application.DisplayAlerts = True
End If
On Error GoTo 0

' Create new ConsolidatedData sheet
Set wsConsolidated = wb.Sheets.Add(After:=wb.Sheets(wb.Sheets.Count))
wsConsolidated.Name = "ConsolidatedData"

' Add headers
wsConsolidated.Cells(1, 1).Value = "Sheet Name"
wsConsolidated.Cells(1, 2).Value = "Previous Date"
wsConsolidated.Cells(1, 3).Value = "Date"
wsConsolidated.Cells(1, 4).Value = "Oil Production"
wsConsolidated.Cells(1, 5).Value = "Gas Production"
' Add more headers as needed based on your data structure

' Initialize output row
rowOutput = 2

' Loop through each worksheet
For Each ws In wb.Worksheets
' Skip the consolidated sheet
If ws.Name <> "ConsolidatedData" Then
' Find last row in the sheet (starting from column A)
lastRow = ws.Cells(ws.Rows.Count, 1).End(xlUp).Row

' Loop through rows starting from row 9
For i = 9 To lastRow
' Check if the row has valid data (e.g., non-empty date in column A)
If Not IsEmpty(ws.Cells(i, 1)) Then
' Copy data to consolidated sheet
wsConsolidated.Cells(rowOutput, 1).Value = ws.Name
' Leave column B (Previous Date) empty
wsConsolidated.Cells(rowOutput, 3).Value = ws.Cells(i, 1).Value ' Raw date
wsConsolidated.Cells(rowOutput, 4).Value = ws.Cells(i, 2).Value ' Oil production
wsConsolidated.Cells(rowOutput, 5).Value = ws.Cells(i, 3).Value ' Gas production
' Add more columns as needed
rowOutput = rowOutput + 1
End If
Next i
End If
Next ws

' Auto-fit columns for readability
wsConsolidated.Columns("A:E").AutoFit

MsgBox "Consolidated data sheet created successfully!", vbInformation
End Sub


Posted by Palomitz
Miami
Member since Oct 2009
2650 posts
Posted on 7/17/25 at 3:45 pm to
Thanks for sharing this!
Posted by gaetti15
AK
Member since Apr 2013
14631 posts
Posted on 7/17/25 at 3:45 pm to
vba macros, gross.

Get better database software
Posted by Mingo Was His NameO
Brooklyn
Member since Mar 2016
35828 posts
Posted on 7/17/25 at 3:50 pm to
The real question is why you’re doing this in excel. Get better data integrity baw
Posted by CAD703X
Liberty Island
Member since Jul 2008
90881 posts
Posted on 7/17/25 at 3:54 pm to
for more VBA macros, hit like and subscribe
Posted by LegendInMyMind
Member since Apr 2019
71034 posts
Posted on 7/17/25 at 3:55 pm to
@grok Are you going to take Clyde's job?
Posted by Clyde Tipton
Planet Earth
Member since Dec 2007
40461 posts
Posted on 7/17/25 at 3:57 pm to
quote:

vba macros, gross.

Get better database software


Cut me some slack. I just learned to ask Grok to code for me.

First I scraped the data from a public information website to create a workbook where each well has it's own sheet and the sheet name is the UWI.

From there this macro created a single line text file with UWI, Start Date, End Date, Oil, Gas. That's the format the software wants it to be in.

This is a new area we are looking at so it did 80 something wells, over 10,000 months of data in the blink of an eye. I was impressed.

A guy in the office next to me realized what I was doing and kept checking in to see how it was going. It took a few attempts and clarifications to get a macro that would work correctly.

quote:

Get better database software


He mentioned Rubber Duck. What do you recommend? I feel like a neanderthal that was just given a Bic lighter. I'm invigorated to see what else I can streamline around here. This process used to take a few days to manually build a spreadsheet. In half a day, I built this module that does it as soon as I press F5.
Posted by Ingeniero
Baton Rouge
Member since Dec 2013
21674 posts
Posted on 7/17/25 at 3:59 pm to
AI is great for stuff like this. It's stupid when people use it for stuff like "GROK give me reasons why the earth could actually be flat!" and present that as evidence in an argument
Posted by LSU Coyote
Member since Sep 2007
56151 posts
Posted on 7/17/25 at 3:59 pm to
This is sooo 2009
Posted by Clyde Tipton
Planet Earth
Member since Dec 2007
40461 posts
Posted on 7/17/25 at 4:03 pm to
quote:


@grok Are you going to take Clyde's job?


We are not a big company. When it came time for the final reveal (I tested it alone first) I had 4 people standing around me when I said,

An audible gasp was heard.

I might get promoted.

Like I said, we are a small consulting company with a lot of old dudes stuck in the old days.
first pageprev pagePage 1 of 1Next pagelast page
refresh

Back to top
logoFollow TigerDroppings for LSU Football News
Follow us on X, Facebook and Instagram to get the latest updates on LSU Football and Recruiting.

FacebookXInstagram