Hi ncaravela
There are a couple of things you could do in regards to the next ID number. The fast thing would be to use a cell on the Página Inicial sheet to hold the next ID number. Change the font to white and the users will not know it is there. If you don't want to risk it being changed, you could create a new sheet to hold the value, and hide it as very hidden.
Otherwise, if you want to continue to use your code method to find the max that has been used:
For the unprotecting and protecting of sheets, you just need to identify which sheet you are unprotecting/protecting, and fill that sheet name in for Base Dados. You can use the same function:
where i will be the month number. You may need to use the date you retrieve in your cmdguardar_Click() procedure to get this i value.
Bookmarks