Mandatory Cells
Mel
I would place code in the Before_Save event in Thisworkbook Module
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Dim cell As Range
For Each cell In Sheets("Sheet1").Range("A2,A3")
If IsEmpty(cell.Value) Then
MsgBox "You must fill in cell " & cell.Address
Application.Goto cell
Cancel = True
Exit For
End If
Next cell
End Sub
If you want users to get a reminder before they try to save, stick this in the
Sheet Module.
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count 1 Then Exit Sub
If Intersect(Target, Me.Range("A1")) Is Nothing Then Exit Sub
On Error GoTo CleanUp
Application.EnableEvents = False
With Target
If .Value = "used" Then
MsgBox "Please fill in cells A2 and A3"
End If
End With
CleanUp:
Application.EnableEvents = True
End Sub
Gord Dibben MS Excel MVP
On Wed, 05 Jul 2006 10:38:49 GMT, "Mel1221 via OfficeKB.com" <u23678@uwe wrote:
Thanks for the response, I need it enough that I'm willing to put in the
effort if you are :o)
Where should I start? Instead of having the code in the Before_Save sub
could it be triggered
when the user changes a particular value?
i.e
When user selects the value "used" from a dropdown in say A1
Then A2 cannot be blank, and A3 cannot be blank....?
Although I'm not too sure how to code this into the worksheet?
Again, hope this makes sense!
Cheers,
Mel
Gord Dibben wrote:
Mel
To "force" a user to enter data in cells requires VBA code.
Either in the Before_Close or Before_Save subs or in a worksheet event code.
Of course, this then requires that the users enable macros in order for the code
to work.
Which leads to more code that shows only a message sheet and hides the others if
the users disable macros.
The message would read similar to .."This workbook is non-usable unless you
re-open it with macros enabled".
The question now becomes.............How much effort and learning are you
willing to invest in this project?
Post back if you really need this. We can try to work you through it.
Gord Dibben MS Excel MVP
sorry bout that...my brain is fried...here goes.
[quoted text clipped - 16 lines]
Much thanks!
Mel
|