LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
al al is offline
external usenet poster
 
Posts: 363
Default Force input in multiple cells in Excel form

I have tried several different things to make this work and need professional
help. I have an Excel form with several fields (11 all together) that
require user input before it can be or should be allowed to be saved.
The first code I tried, and I was new at this with Excel, was to try
multiple actions like the following (which did not work) Oh, I should say
that it worked for the very first cell but none after that:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Range("E10").Value = "" Then
On Error Resume Next
Application.EnableEvents = False
Range("E10").Select
Application.EnableEvents = True
MsgBox ("You must enter a value for 'Department Name'")
End If
End Sub

Private Sub Worksheet_SelectionChange1(ByVal Target As Range)
If Range("E11").Value = "" Then
On Error Resume Next
Application.EnableEvents = False
Range("E11").Select
Application.EnableEvents = True
MsgBox ("You must enter a value for 'Address'")
End If
End Sub

Private Sub Worksheet_SelectionChange2(ByVal Target As Range)
If Range("E12").Value = "" Then
On Error Resume Next
Application.EnableEvents = False
Range("E12").Select
Application.EnableEvents = True
MsgBox ("You must enter a value for 'Contract Type'")
End If
End Sub
..
..
..
Then I realized it was not working because I was changing the very name of
the action that made it work "Worksheet_SelectionChange" so I tried nesting
the If statements, which also did not work:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Excel.ActiveCell = E10 Then
If Range("E10").Value = "" Then
On Error Resume Next
Application.EnableEvents = False
Range("E10").Select
Application.EnableEvents = True
MsgBox ("Please enter a Department Name")
End If
Else
If Excel.ActiveCell = E11 Then
If Range("E11").Value = "" Then
On Error Resume Next
Application.EnableEvents = False
Range("E11").Select
Application.EnableEvents = True
MsgBox ("Please enter an Address")

End If

Else
If Excel.ActiveCell = E12 Then
If Range("E12").Value = "" Then
On Error Resume Next
Application.EnableEvents = False
Range("E12").Select
Application.EnableEvents = True
MsgBox ("Please enter a 'Contract Type'")
End If

Else
If Excel.ActiveCell = E13 Then
If Range("E12").Value = "" Then
On Error Resume Next
Application.EnableEvents = False
Range("E12").Select
Application.EnableEvents = True
MsgBox ("Please enter a 'Contract Document Type'")
End If

Else
If Excel.ActiveCell = E14 Then
If Range("E12").Value = "" Then
On Error Resume Next
Application.EnableEvents = False
Range("E12").Select
Application.EnableEvents = True
MsgBox ("Please enter a Contractor")
End If

Else
If Excel.ActiveCell = E15 Then
If Range("E12").Value = "" Then
On Error Resume Next
Application.EnableEvents = False
Range("E12").Select
Application.EnableEvents = True
MsgBox ("Please enter a Contractor Address")
End If
..
..
..
Ok, so I thought I need to simplify this and went to a Select Case
statement, which of course also does not work:
Private Sub Contract_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Select Case Excel.Range
Case "E10" = ""
MsgBox "Please enter enter a Department Name"
Cancel = True 'cancels the save event
Case "E11" = ""
MsgBox "Please enter an Address"
Cancel = True 'cancels the save event
Case "E12" = ""
MsgBox "Please enter a 'Contract Type'"
Cancel = True 'cancels the save event
Case "E13" = ""
MsgBox "Please enter a 'Contract Document Type'"
Cancel = True 'cancels the save event
Case "E14" = ""
MsgBox "Please enter a Contractor"
Cancel = True 'cancels the save event
Case "E15" = ""
MsgBox "Please enter a Contractor Address"
Cancel = True 'cancels the save event
Case "E17" = ""
MsgBox "Please enter a Project Title"
Cancel = True 'cancels the save event
Case "O10" = ""
MsgBox "Please enter a Contact Name"
Cancel = True 'cancels the save event
Case "O11" = ""
MsgBox "Please enter a Telephone Number"
Cancel = True 'cancels the save event
Case "A23" = ""
MsgBox "Please enter a Summary"
Cancel = True 'cancels the save event
Case "A44" = ""
MsgBox "Please enter a Request for Action Description"
Cancel = True 'cancels the save event
End Select
End Sub

I am hoping that someone has seen or done something like this and can tell
me that this is possible. I really appreciate any help you can provide.

Thank you in advance,
Al
 
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
How to clear multiple cells of input data in Excel simultaneously sstea Excel Worksheet Functions 12 May 2nd 09 08:47 PM
Force a number input Gunti Excel Discussion (Misc queries) 2 February 5th 09 11:18 AM
Link input cells on user form to macro SteveDB1 Excel Programming 8 December 4th 07 08:52 AM
Is there way to enter multiple values into excel cells w/ a form? grassfed Excel Discussion (Misc queries) 1 June 22nd 05 05:26 PM
Excel VBA -Force users to populate custom form cells tschultz Excel Programming 1 April 2nd 04 07:17 PM


All times are GMT +1. The time now is 08:00 AM.

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"