Making a button to fill a cell with next data in line

I use CALC to make invoices for clients. I use SHEETS in a file, called 2023(for the year), for each invoice that is currently “in process” i.e. not finished yet.

I have a master SHEET in the “2023” file that contains a column called “INVOICE#” that is just a series of numbers starting at 23001. Each time I generate a new invoice, I add “1” to that number and record the total dollar amount the next column over called “INV TOTAL”.

I make a new SHEET for each invoice and only when they are finished do I then give them an invoice number.

I manually look at the master sheet and see which invoice number I have used last and give the new invoice the next number.

I would like a button that looks at the next “unused” invoice number and fills in a particular cell on the invoice / sheet.

There are actually four different cells that need to be analyzed and any data. If any data is found then that invoice number would need to be skipped in favor of the next blank one.

Is this possible?

Possible? Sure.
.
But Buttons don’t “do” much. Actually you will need a macro, doing the stuff you ask. The macro can be bound to a button. To write this macro precise information is necessary. Your “There are actually four different cells that need to be analyzed” is not enough.
.
Your appoach seems quite complicated. Usually I’d expect a simple MAX(column)+1 should be sufficient for invoice-numbers, but specifications are up to you…