Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Required Data in cell

Is there a way to require that a particular cell be populated prior to saving
an Excel file (one cell is text and one is a date field)? We are using a
spreadsheet to collect data from users that is later used to feed an Access
database and need to be sure that the source file has these two key cells
populated.

Thank you -
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Required Data in cell

Got it - because I am not a programmer I need help in knowing the code to
check that cell T8 is not blank and the same for cell C3. If it is blank,
can we generate a dialog box informing the user that they are required fields?

Also, is there a way to automatically enable the macros when opening the
file without prompting the user now that we are adding a macro?

Thanks again -

"Don Guillett" wrote:

Look in the ThisWorkbook module for the before_save event

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"cmac" wrote in message
...
Is there a way to require that a particular cell be populated prior to
saving
an Excel file (one cell is text and one is a date field)? We are using a
spreadsheet to collect data from users that is later used to feed an
Access
database and need to be sure that the source file has these two key cells
populated.

Thank you -



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Required Data in cell

Hi,

Alt+F11 to open VB editor. Double click 'This workbook' and paste this in on
the right . Change ranges and sheet to suit

Private Sub Workbook_BeforeClose(Cancel As Boolean)
If Not IsDate(Sheets("Sheet1").Range("A1")) _
Or IsEmpty(Sheets("Sheet1").Range("A2")) Then
MsgBox "Some sort of dire warning"
Cancel = True
End If
End Sub

Mike

"cmac" wrote:

Is there a way to require that a particular cell be populated prior to saving
an Excel file (one cell is text and one is a date field)? We are using a
spreadsheet to collect data from users that is later used to feed an Access
database and need to be sure that the source file has these two key cells
populated.

Thank you -

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Required Data in cell

Hi,

I probaly meant before save.

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
If Not IsDate(Sheets("Sheet1").Range("A1")) _
Or IsEmpty(Sheets("Sheet1").Range("A2")) Then
MsgBox "Some sort of dire warning"
Cancel = True
End If
End Sub


Mike

"Mike H" wrote:

Hi,

Alt+F11 to open VB editor. Double click 'This workbook' and paste this in on
the right . Change ranges and sheet to suit

Private Sub Workbook_BeforeClose(Cancel As Boolean)
If Not IsDate(Sheets("Sheet1").Range("A1")) _
Or IsEmpty(Sheets("Sheet1").Range("A2")) Then
MsgBox "Some sort of dire warning"
Cancel = True
End If
End Sub

Mike

"cmac" wrote:

Is there a way to require that a particular cell be populated prior to saving
an Excel file (one cell is text and one is a date field)? We are using a
spreadsheet to collect data from users that is later used to feed an Access
database and need to be sure that the source file has these two key cells
populated.

Thank you -



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Required Data in cell

Thanks to all for your help - it works great and I am learning from each of
you.

"Mike H" wrote:

Hi,

Alt+F11 to open VB editor. Double click 'This workbook' and paste this in on
the right . Change ranges and sheet to suit

Private Sub Workbook_BeforeClose(Cancel As Boolean)
If Not IsDate(Sheets("Sheet1").Range("A1")) _
Or IsEmpty(Sheets("Sheet1").Range("A2")) Then
MsgBox "Some sort of dire warning"
Cancel = True
End If
End Sub

Mike

"cmac" wrote:

Is there a way to require that a particular cell be populated prior to saving
an Excel file (one cell is text and one is a date field)? We are using a
spreadsheet to collect data from users that is later used to feed an Access
database and need to be sure that the source file has these two key cells
populated.

Thank you -

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default Required Data in cell

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, _
Cancel As Boolean)
Application.DisplayAlerts = False
With Sheets("Sheet1")
If .Range("C3") = "" Or .Range("T8") = "" Then
MsgBox "fill in C3 and T8"
Cancel = True
Else
ActiveWorkbook.Save
End If
End With
Application.DisplayAlerts = True
End Sub

This is workbook event code.

Right-click on the Excel Icon left of "File" and "View Code"

Copy/paste into that module.

As far as having no macros warning, without all users setting security to
"Low"(not recommended) you would need to digitally sign the workbook.


Gord Dibben MS Excel MVP

On Wed, 8 Oct 2008 12:22:04 -0700, cmac
wrote:

Is there a way to require that a particular cell be populated prior to saving
an Excel file (one cell is text and one is a date field)? We are using a
spreadsheet to collect data from users that is later used to feed an Access
database and need to be sure that the source file has these two key cells
populated.

Thank you -


  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Required Data in cell

Is there a way to save a template with these fields blank and then force the
check going forward?

"Gord Dibben" wrote:

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, _
Cancel As Boolean)
Application.DisplayAlerts = False
With Sheets("Sheet1")
If .Range("C3") = "" Or .Range("T8") = "" Then
MsgBox "fill in C3 and T8"
Cancel = True
Else
ActiveWorkbook.Save
End If
End With
Application.DisplayAlerts = True
End Sub

This is workbook event code.

Right-click on the Excel Icon left of "File" and "View Code"

Copy/paste into that module.

As far as having no macros warning, without all users setting security to
"Low"(not recommended) you would need to digitally sign the workbook.


Gord Dibben MS Excel MVP

On Wed, 8 Oct 2008 12:22:04 -0700, cmac
wrote:

Is there a way to require that a particular cell be populated prior to saving
an Excel file (one cell is text and one is a date field)? We are using a
spreadsheet to collect data from users that is later used to feed an Access
database and need to be sure that the source file has these two key cells
populated.

Thank you -



  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default Required Data in cell

Not sure what you mean.

By Template do you mean an *.xlt file that you create new workbooks from?

If so, you could add the code to the Template


Gord

On Thu, 16 Oct 2008 13:31:02 -0700, cmac
wrote:

Is there a way to save a template with these fields blank and then force the
check going forward?

"Gord Dibben" wrote:

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, _
Cancel As Boolean)
Application.DisplayAlerts = False
With Sheets("Sheet1")
If .Range("C3") = "" Or .Range("T8") = "" Then
MsgBox "fill in C3 and T8"
Cancel = True
Else
ActiveWorkbook.Save
End If
End With
Application.DisplayAlerts = True
End Sub

This is workbook event code.

Right-click on the Excel Icon left of "File" and "View Code"

Copy/paste into that module.

As far as having no macros warning, without all users setting security to
"Low"(not recommended) you would need to digitally sign the workbook.


Gord Dibben MS Excel MVP

On Wed, 8 Oct 2008 12:22:04 -0700, cmac
wrote:

Is there a way to require that a particular cell be populated prior to saving
an Excel file (one cell is text and one is a date field)? We are using a
spreadsheet to collect data from users that is later used to feed an Access
database and need to be sure that the source file has these two key cells
populated.

Thank you -




  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Required Data in cell

Sorry,

Using an xls file that is a standard format that is distributed to others to
gather standard information in the same format. This file is made available
to the others who complete/provide the requested information.

"Gord Dibben" wrote:

Not sure what you mean.

By Template do you mean an *.xlt file that you create new workbooks from?

If so, you could add the code to the Template


Gord

On Thu, 16 Oct 2008 13:31:02 -0700, cmac
wrote:

Is there a way to save a template with these fields blank and then force the
check going forward?

"Gord Dibben" wrote:

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, _
Cancel As Boolean)
Application.DisplayAlerts = False
With Sheets("Sheet1")
If .Range("C3") = "" Or .Range("T8") = "" Then
MsgBox "fill in C3 and T8"
Cancel = True
Else
ActiveWorkbook.Save
End If
End With
Application.DisplayAlerts = True
End Sub

This is workbook event code.

Right-click on the Excel Icon left of "File" and "View Code"

Copy/paste into that module.

As far as having no macros warning, without all users setting security to
"Low"(not recommended) you would need to digitally sign the workbook.


Gord Dibben MS Excel MVP

On Wed, 8 Oct 2008 12:22:04 -0700, cmac
wrote:

Is there a way to require that a particular cell be populated prior to saving
an Excel file (one cell is text and one is a date field)? We are using a
spreadsheet to collect data from users that is later used to feed an Access
database and need to be sure that the source file has these two key cells
populated.

Thank you -






  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default Required Data in cell

Still not sure what "going forward" refers to.

The same workbook is distributed to others or copies of the workbook are
distributed to others?

Whatever the case, make sure the code is in every workbook that would be
sent out.


Gord

On Fri, 17 Oct 2008 05:14:10 -0700, cmac
wrote:

Sorry,

Using an xls file that is a standard format that is distributed to others to
gather standard information in the same format. This file is made available
to the others who complete/provide the requested information.

"Gord Dibben" wrote:

Not sure what you mean.

By Template do you mean an *.xlt file that you create new workbooks from?

If so, you could add the code to the Template


Gord

On Thu, 16 Oct 2008 13:31:02 -0700, cmac
wrote:

Is there a way to save a template with these fields blank and then force the
check going forward?

"Gord Dibben" wrote:

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, _
Cancel As Boolean)
Application.DisplayAlerts = False
With Sheets("Sheet1")
If .Range("C3") = "" Or .Range("T8") = "" Then
MsgBox "fill in C3 and T8"
Cancel = True
Else
ActiveWorkbook.Save
End If
End With
Application.DisplayAlerts = True
End Sub

This is workbook event code.

Right-click on the Excel Icon left of "File" and "View Code"

Copy/paste into that module.

As far as having no macros warning, without all users setting security to
"Low"(not recommended) you would need to digitally sign the workbook.


Gord Dibben MS Excel MVP

On Wed, 8 Oct 2008 12:22:04 -0700, cmac
wrote:

Is there a way to require that a particular cell be populated prior to saving
an Excel file (one cell is text and one is a date field)? We are using a
spreadsheet to collect data from users that is later used to feed an Access
database and need to be sure that the source file has these two key cells
populated.

Thank you -





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Conditional Formatting based on data in adjacent cell & restrict save without required data bjohnson Excel Programming 1 August 28th 07 10:27 PM
How do I work on data starting to a cell a cell with a required va Tom London Excel Programming 6 October 22nd 06 04:46 PM
Removing lines of data that do not contain required data (macro) Sean[_7_] Excel Programming 1 May 21st 04 03:53 PM
Cell data required upon close pjhageman[_11_] Excel Programming 2 January 12th 04 02:45 PM
Change Cell Data of a Required Column jonathan Excel Programming 0 January 8th 04 09:28 PM


All times are GMT +1. The time now is 05:20 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"