#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default Forms in Excel

I am creating a form in excel and have certain cells which need to be filled
before I can accept the form is there a way to set the form up that certain
cells would need information in them before the file could be saved.

Any help with this would be appreciated.
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Forms in Excel

Maybe....

Saved from a previous post:

Option Explicit
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)

Dim myRng As Range
Dim myEmptyRng As Range
Dim myCell As Range

Set myRng = Me.Worksheets("Form").Range("a1,b9,c12,d13")

If Application.CountA(myRng) 0 _
And Application.CountA(myRng) < myRng.Cells.Count Then
Cancel = True
For Each myCell In myRng.Cells
If IsEmpty(myCell) Then
If myEmptyRng Is Nothing Then
Set myEmptyRng = myCell
Else
Set myEmptyRng = Union(myEmptyRng, myCell)
End If
End If
Next myCell
MsgBox myEmptyRng.Address(0, 0) & " must have valid data!"
End If
End Sub

If all the cells are empty, you can still save (nice for changing the master).
But there are other techniques if you don't want to allow all empty cells.

this code goes behind the ThisWorkbook module.

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

Jinxy wrote:

I am creating a form in excel and have certain cells which need to be filled
before I can accept the form is there a way to set the form up that certain
cells would need information in them before the file could be saved.

Any help with this would be appreciated.


--

Dave Peterson
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
Can I use Access forms in Excel Capbl Excel Discussion (Misc queries) 0 June 6th 06 03:25 PM
Can I use Access forms in Excel? Capbl Excel Discussion (Misc queries) 0 June 6th 06 03:23 PM
Forms in Excel 2007 Ben Enfield Excel Worksheet Functions 2 June 2nd 06 11:11 AM
Customize forms in Excel anna Excel Discussion (Misc queries) 1 June 1st 06 03:00 PM
Excel Forms - text fields decompressing font automatically EM Excel Discussion (Misc queries) 0 March 11th 05 03:37 PM


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

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

About Us

"It's about Microsoft Excel"