ChatGPT vs. Grok for programming Microsoft Excel
At the end of last year, I wanted to clean up some mailing addresses in an Excel spreadsheet for use with our family New Year’s cards. I resent having to spend time learning any computer language other than Lisp and SQL unless that language is more powerful than Lisp and/or SQL. Thus, I’ve never become a proficient Excel programmer. Could an LLM come to my rescue?
Prompt to ChatGPT 5.2:
write a Microsoft Excel 365 formula that will take a US address and remove a trailing “US” or “US” preceded by a newline and also turn any 9-digit ZIP code into a 5-digit zip code by removing “-NNNN” where N is a digit.
Answer:
=REGEXREPLACE(
REGEXREPLACE(A1,"(\d{5})-\d{4}","$1"),
"(\r?\n)?US$",""
)
Grok’s answer:
=LET(
cleaned, TRIM(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1,CHAR(10)&"US",""),CHAR(10)," ")," US","")),
lastLine, TRIM(RIGHT(cleaned, LEN(cleaned)-FIND("@",SUBSTITUTE(cleaned," ","@",LEN(cleaned)-LEN(SUBSTITUTE(cleaned," ","")))))),
zipLike, TRIM(TEXTAFTER(lastLine," ",-1,"",1)),
fixedZip, IF(REGEXTEST(zipLike,"^\d{5}(-\d{4})?$"),
LEFT(zipLike,5),
zipLike),
SUBSTITUTE(cleaned, zipLike, fixedZip)
)
What’s the difference between these, other than Grok’s epic verbosity? The Grok version results in an unexplained error from Excel while the ChatGPT code works.
Advantage: ChatGPT
Full post, including comments






















