- My Forums
- Tiger Rant
- LSU Recruiting
- SEC Rant
- Saints Talk
- Pelicans Talk
- More Sports Board
- Coaching Changes
- Fantasy Sports
- Golf Board
- Soccer Board
- O-T Lounge
- Tech Board
- Home/Garden Board
- Outdoor Board
- Health/Fitness Board
- Movie/TV Board
- Book Board
- Music Board
- Political Talk
- Money Talk
- Fark Board
- Gaming Board
- Travel Board
- Food/Drink Board
- Ticket Exchange
- TD Help Board
Customize My Forums- View All Forums
- Show Left Links
- Topic Sort Options
- Trending Topics
- Recent Topics
- Active Topics
Started By
Message
Grok is a Beast...
Posted on 7/17/25 at 3:37 pm
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.
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 on 7/17/25 at 3:45 pm to Clyde Tipton
Thanks for sharing this!
Posted on 7/17/25 at 3:45 pm to Clyde Tipton
vba macros, gross.
Get better database software
Get better database software
Posted on 7/17/25 at 3:50 pm to Clyde Tipton
The real question is why you’re doing this in excel. Get better data integrity baw
Posted on 7/17/25 at 3:54 pm to Clyde Tipton
for more VBA macros, hit like and subscribe
Posted on 7/17/25 at 3:55 pm to Clyde Tipton
@grok Are you going to take Clyde's job?
Posted on 7/17/25 at 3:57 pm to gaetti15
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 on 7/17/25 at 3:59 pm to Clyde Tipton
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 on 7/17/25 at 4:03 pm to LegendInMyMind
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.
Popular
Back to top

7








