Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
SeattleKurt
 
Posts: n/a
Default Creating mandatory fields(cells)...


I'm an estimator who uses excel to enter data for jobs. There are some
fields that will ALWAYS need to have something in them. Is there a way
that I can format these cells so that if I try and save before they are
filled, I get an error?

Thanks so much!


--
SeattleKurt
------------------------------------------------------------------------
SeattleKurt's Profile: http://www.excelforum.com/member.php...o&userid=26846
View this thread: http://www.excelforum.com/showthread...hreadid=400894

  #2   Report Post  
Dave Peterson
 
Posts: n/a
Default

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

SeattleKurt wrote:

I'm an estimator who uses excel to enter data for jobs. There are some
fields that will ALWAYS need to have something in them. Is there a way
that I can format these cells so that if I try and save before they are
filled, I get an error?

Thanks so much!

--
SeattleKurt
------------------------------------------------------------------------
SeattleKurt's Profile: http://www.excelforum.com/member.php...o&userid=26846
View this thread: http://www.excelforum.com/showthread...hreadid=400894


--

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
Creating custom list with a comma in it barnabel Excel Discussion (Misc queries) 6 January 10th 06 06:14 AM
creating lists maebeeso New Users to Excel 1 July 18th 05 06:55 PM
Eliminate creating list that returns blank cells Marc Todd Excel Worksheet Functions 1 January 26th 05 09:58 PM
How to create mandatory cells in a worksheet prakash Excel Worksheet Functions 0 January 15th 05 02:03 PM
creating an x,y chart smintey Charts and Charting in Excel 2 December 16th 04 11:11 PM


All times are GMT +1. The time now is 02:18 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"