Websites, apps & code / Coding & debugging

Excel macro (VBA)

A repeated Excel routine that you want done with one button.

Fill in your details

Leave blank to use the example. Names are remembered for other prompts too (stored only on your device).

Variation:Your Excel

Prompt

Write an Excel macro that turns a repeated chore into one button.

What I do by hand now: Every month copy figures from 3 tabs into a "Summary" tab and sort by date
Sheet layout: Tabs Jan, Feb, Mar; column A date, column B amount; row 1 headings
My Excel: Explain how to open the Developer tab.

Please:
1. Ask me 3 questions, then restate it in one sentence and write only after I say it is right.
2. Be careful: show what will change before it runs, never delete my original data, and put results in a new place.
3. Teach me where to paste it and how to run it, step by step, and remind me to save a backup copy first.
4. Add short comments on each part.
5. Give me a small test using fake data and say what I should see.
6. No commands that use the internet or read other files unless you ask me first.

Paste it into ChatGPT, Gemini, Claude or Meta AI.

Test result

Run on 2026-12-01 with Claude Sonnet 5.5 (variation: Excel on Windows), using the example details above. AI never answers word for word the same twice, but the shape stays close.

What we noticed

The AI asked 3 questions, restated the need and gave only a commented skeleton, since the prompt says to wait for my yes. The small test used 3 fake rows. The skeleton was not run in a real Excel.

See what the AI actually wrote

I won't write it yet; 3 questions first:

  1. Should the Summary keep what you copied in last month, or be emptied each time? (I suggest a new tab each run and never clearing old ones.)
  2. Is the sort "date oldest to newest"? If several rows share a date, keep their original order?
  3. Is your Excel Windows or Mac? (The macro is the same, but the path to the Developer tab differs.)

My understanding in one sentence: a button that first tells you what it will do and, after you confirm, copies columns A and B (skipping the heading row) from the Jan, Feb and Mar tabs into a new tab "Summary_merged" and sorts it by the date in column A, without changing or deleting the original three tabs. I only write it once you say that is right.

Opening the Developer tab:

  • Windows: File > Options > Customize Ribbon > tick "Developer" on the right.
  • Mac: Excel > Preferences > Ribbon & Toolbar > tick "Developer".
  • Also save as a macro-enabled workbook (.xlsm) or the macro cannot be kept. Save a backup copy of the original file first.

The macro's shape (a skeleton first, the full version after you confirm):

Sub MergeThreeMonths()
    ' 1. Prompt first: only a new tab "Summary_merged" is created, originals untouched
    If MsgBox("Copy Jan/Feb/Mar into a new tab 'Summary_merged' and sort by date. Original tabs will not be changed. Continue?", vbYesNo) = vbNo Then Exit Sub
    ' 2. Create the new tab (if it exists, stop and warn; never overwrite)
    ' 3. Copy columns A:B from each tab, heading row only once
    ' 4. Sort by the date in column A
    ' 5. Report done, with how many rows were merged
End Sub

The full version will carry a short explanation on each part.

Pasting it in: Developer > Visual Basic > Insert > Module > paste > close. Back in the sheet, Developer > Insert > Button, and assign this macro.

Small test (fake data):
Jan: 2025-01-05 / 100; Feb: 2025-02-03 / 200; Mar: 2025-03-01 / 50
After running, "Summary_merged" should have 1 heading row plus 3 rows ordered Jan, Feb, Mar, with a message "merged 3 rows". Then change the Jan date to 2025-03-05; that row should move to the end.

Safety: this macro uses no internet and reads no other files.

Answer the 3 questions and say "right" and I will write the full version.

AI tools that suit this

  • ChatGPT Suggested tool Free plan

    The most widely used AI chat, for writing, questions and images

  • Claude Suggested tool Free plan

    Strong at long documents, editing and code

  • Microsoft Copilot Suggested tool Free plan

    Handy alongside Word, Excel and Outlook

Recommendations only, not sponsored. Check each site for what the free plan includes.

This site is made by FullMark Tech

Want your own website, or your shop spreadsheets automated? FullMark Tech builds business websites and custom Excel tools.

Ask on WhatsApp See FullMark Tech services