I want to use the spreadsheet as form for users to fill out. Some cells require values to be entered. What would the code look like to perform a check when saving or closing that ensures certain cells (lets say a2 and b3) are not left empty
I want to use the spreadsheet as form for users to fill out. Some cells require values to be entered. What would the code look like to perform a check when saving or closing that ensures certain cells (lets say a2 and b3) are not left empty
Try this in ThisWorkbook module
orPlease Login or Register to view this content.
VBA NoobPlease Login or Register to view this content.
Last edited by VBA Noob; 09-25-2008 at 04:54 PM.
_________________________________________
Credo Elvem ipsum etian vivere
_________________________________________
A message for cross posters
Please remember to wrap code.
Forum Rules
Please add to your signature if you found this link helpful. Excel links !!!
Use the "on close" or "on save" event to do this when the user tries to do one of these actions. For either, within the VBA window, select ThisWorkbook and from the left drop down select Workbook and from right dropdown you'll see a list of possible events .. The ones you're suggesting are BeforeSave and BeforeClose. I suggest BeforeSave because the user may choose to close without completing the form and if you trap them there they won't be able to ... very annoying.
So - selecting BeforeSave will give you the sub structure:
Here's a suggestion:Please Login or Register to view this content.
Hope that helps.Please Login or Register to view this content.
MatrixMan.
--------------------------------------
If this - or any - reply helps you, remember to say thanks by clicking on *Add Reputation.
If your issue is now resolved, remember to mark as solved - click Thread Tools at top right of thread.
Could you expand on this a bit?
If input is entered into column C (range C2:C100), then columns D, E ,F, H and I must not be blank upon save.
An error msg pops up upon attempt to save and colors each cell yellow that lacks info yellow?
---------- Post added at 10:16 AM ---------- Previous post was at 10:15 AM ----------
Sorry...I'm using Excel 2010.
ScottyDo,
Welcome to the Forum, unfortunately:
Your post does not comply with Rule 2 of our Forum RULES. Don't post a question in the thread of another member -- start your own thread. If you feel it's particularly relevant, provide a link to the other thread. It makes sense to have a new thread for your question because a thread with numerous replies can be off putting & difficult to pick out relevant replies.
If I have helped, Don't forget to add to my reputation (click on the star below the post)
Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
Use code tags when posting your VBA code: [code] Your code here [/code]
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks