ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   mandatory field (https://www.excelbanter.com/excel-discussion-misc-queries/121942-mandatory-field.html)

flow23

mandatory field
 
I have a sheet for user to input data. However filed in column C,D,H and J
are mandatory.
The file shouldnt save if data isnt entered into any of these columns.

any help


Don Guillett

mandatory field
 
Particular sheet____________
Particular row_____________

Put this in the ThisWorkbook module

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
If Application.CountA(Sheets("sheet9").Range("c2,d2,h 2,j2")) < 4 Then
Cancel = True
MsgBox "Not finished"
End If
End Sub

--
Don Guillett
SalesAid Software

"flow23" wrote in message
...
I have a sheet for user to input data. However filed in column C,D,H and J
are mandatory.
The file shouldnt save if data isnt entered into any of these columns.

any help




flow23

mandatory field
 
well thats the problem, the user can go on creating rows and rows of data.
but in the end when he/she saves, the columns for those rows should have
some data.



"Don Guillett" wrote:

Particular sheet____________
Particular row_____________

Put this in the ThisWorkbook module

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
If Application.CountA(Sheets("sheet9").Range("c2,d2,h 2,j2")) < 4 Then
Cancel = True
MsgBox "Not finished"
End If
End Sub

--
Don Guillett
SalesAid Software

"flow23" wrote in message
...
I have a sheet for user to input data. However filed in column C,D,H and J
are mandatory.
The file shouldnt save if data isnt entered into any of these columns.

any help





Bernie Deitrick

mandatory field
 
When do you consider a row "Created"?

HTH,
Bernie
MS Excel MVP


"flow23" wrote in message
...
well thats the problem, the user can go on creating rows and rows of data.
but in the end when he/she saves, the columns for those rows should have
some data.



"Don Guillett" wrote:

Particular sheet____________
Particular row_____________

Put this in the ThisWorkbook module

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
If Application.CountA(Sheets("sheet9").Range("c2,d2,h 2,j2")) < 4 Then
Cancel = True
MsgBox "Not finished"
End If
End Sub

--
Don Guillett
SalesAid Software

"flow23" wrote in message
...
I have a sheet for user to input data. However filed in column C,D,H and J
are mandatory.
The file shouldnt save if data isnt entered into any of these columns.

any help







Don Guillett

mandatory field
 
Still not specific enough. If you know how many rows you could just add up
the columns and divide by the rows and if not the proper number then don't
save.

--
Don Guillett
SalesAid Software

"flow23" wrote in message
...
well thats the problem, the user can go on creating rows and rows of data.
but in the end when he/she saves, the columns for those rows should have
some data.



"Don Guillett" wrote:

Particular sheet____________
Particular row_____________

Put this in the ThisWorkbook module

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
If Application.CountA(Sheets("sheet9").Range("c2,d2,h 2,j2")) < 4 Then
Cancel = True
MsgBox "Not finished"
End If
End Sub

--
Don Guillett
SalesAid Software

"flow23" wrote in message
...
I have a sheet for user to input data. However filed in column C,D,H and
J
are mandatory.
The file shouldnt save if data isnt entered into any of these columns.

any help







Don Guillett

mandatory field
 
Assumes col A has an entry by which to count the number of rows

mtotal =
Application.CountA(Sheets("sheet9").Range("c2,d2,h 2,j2").EntireColumn)
needed = Application.CountA(Sheets("sheet9").Columns(1)) * 4
If mtotal < needed Then
Cancel = True
MsgBox needed
End If

--
Don Guillett
SalesAid Software

"flow23" wrote in message
...
well thats the problem, the user can go on creating rows and rows of data.
but in the end when he/she saves, the columns for those rows should have
some data.



"Don Guillett" wrote:

Particular sheet____________
Particular row_____________

Put this in the ThisWorkbook module

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
If Application.CountA(Sheets("sheet9").Range("c2,d2,h 2,j2")) < 4 Then
Cancel = True
MsgBox "Not finished"
End If
End Sub

--
Don Guillett
SalesAid Software

"flow23" wrote in message
...
I have a sheet for user to input data. However filed in column C,D,H and
J
are mandatory.
The file shouldnt save if data isnt entered into any of these columns.

any help








All times are GMT +1. The time now is 04:09 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com