Mandatory Cells and knowing to fill in the next row!

I heart Excel

Board Regular
Joined
Feb 28, 2011
Messages
66
Hello,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>
<o:p></o:p>
I am very stuck on something I have been looking at for a while.<o:p></o:p>
<o:p></o:p>
I have a spreadsheet for adding new items to our internal system, with numerous headers.<o:p></o:p>
Some of the fields (but not all) are mandatory.<o:p></o:p>
This is filled out and then saved by our users, and then checked daily by me.<o:p></o:p>
<o:p></o:p>
I would like to know if there is anyway of creating a macro or something to make the fields I require mandatory? <o:p></o:p>
I would then like this macro to know that it is to only run on the next blank row. <o:p></o:p>
<o:p></o:p>
Eventually I would like my users to enter the items they require, fill out all the mandatory fields before being able to save, or they get an error message.<o:p></o:p>
When the next person accesses the form to enter their data underneath, it will again, not allow them to save until all the mandatory fields are filled out.<o:p></o:p>

Help will be much appreciated,

Thanks in advance
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Hi and welcome to the board!!!
A few assumptions for coding purposes. You will need to edit for your needs.
1) Sheet1 is the sheet of interest!
2) There is data in Column "A".
3) You have 6 Columns of data.

Place this in the ThisWorkBook module
Code:
Public LR As Long
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
If Application.WorksheetFunction.CountA(Sheet1.Cells(LR + 1, "A").Resize(1, 6)) <> 6 Then
   rspn = MsgBox("You have missed one or more required fields!!" & Chr(10) & "Do you wish to save anyway?", vbYesNo)
   If rspn = vbNo Then Cancel = True
End If
End Sub
Private Sub Workbook_Open()
LR = Sheet1.Cells(Rows.Count, "A").End(xlUp).Row
MsgBox LR
End Sub

Depending on your layout, you may need to make adjustments using a Union of your cells instead of the Resize property!!
HTH
lenze
 
Upvote 0

Forum statistics

Threads
1,224,586
Messages
6,179,730
Members
452,939
Latest member
WCrawford

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top