• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

After save code error

Tom22

Member
Hi,

I am looking for some help here. Attached sheet has 2 macros (before close and after save)
What I am looking is user fill some information in green cells and then close
First macro will take care of this part, it will force user to fill green fields and then it will allow them to close
Second part where I need these fields to get locked once they close the workbook.

Here I am not able to make any success. 2nd code gives me error like "Unable to set the locked property of the range class"
I don't know but to me range is correct .
Can anyone please lookinto this.

Many thanks in advance.
Tom
 

Attachments

  • Test Book.xlsm
    22.2 KB · Views: 4
Hello,

this is not go as expected so I have made some changes.
Now instead of after close and all, I want to create button , where they can submit their data by clicking on save & close button.

now I need a macro which will first
step 1 check if all fields are filled or not , if not then throw a message (that part is done)

step 2 if everything is filled then it will go to next part which is it will locked all the green fields

step3 Saved &close the file

but if all fields are not filled then code should stop their after throwing the message without forwarding to step 2 and 3

This is where I am not sure how to formulate the code.

Can anyone check and suggest please.

File attached
Thanks
 

Attachments

  • Test book 2.xlsm
    22.5 KB · Views: 1
Usually when a new question has no relation with the initial post a new thread must be created …​
As Excel has no field, clearly described what you mean by « all fields » or​
you must be very confident with your Excel / VBA skills in order to amend any code !​
You can also post your code here using the appropriate code tags via the icon in the 3 dots menu​
as some helpers may read your question on a device where they can't open any attachment …​
 
A message box sample in this thread :​
 
Back
Top