LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Forcing Data Entry in Certain Fields at Certain Times

Because I'm limited to worksheet events in the embedded environment her
is a reworked version that informs the user that they must fill in th
first 3 cells of a row if they fill in any of the values. This i
triggered when the user moves to a new row.


Code
-------------------

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If PreviousRowRef = 0 Then
PreviousRowRef = Target.Row
End If

RowRef = Target.Row
ColumnRef = Target.Column

If PreviousRowRef < Target.Row Then
Set ws = Application.ActiveSheet
WithData = 0
FirstColumn = 1
LastColumn = 3 'Number of columns to check
For Each c In ws.Range(Cells(PreviousRowRef, FirstColumn), Cells(PreviousRowRef, LastColumn))
'Check all mandatory fields for this row have been completed
If c.Value < "" Then
WithData = WithData + 1
End If
Next c
If WithData < LastColumn And WithData < 0 Then
MsgBox "Please enter values in Row " + CStr(PreviousRowRef) + ", Cells " + CStr(FirstColumn) + " to " + CStr(LastColumn), vbOKOnly, "Fill in Mandatory cell value"
End If
End If
PreviousRowRef = Target.Row
End Sub

-------------------


--
Message posted from http://www.ExcelForum.com

 
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
CLear Data Entry Form Fields Tony Excel Discussion (Misc queries) 2 January 21st 09 11:57 PM
Data Form does not allow entry in some fields JR Hester Excel Discussion (Misc queries) 4 March 12th 08 11:29 PM
Forcing an entry [email protected] Excel Discussion (Misc queries) 3 October 19th 06 10:04 PM
Checking & Forcing Data Entry in Cells robertguy Excel Discussion (Misc queries) 1 January 23rd 06 06:01 PM
Forcing Combo box entry in VBA Anthony Slater Excel Discussion (Misc queries) 1 December 1st 04 03:09 PM


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