Help in null validations cell

abdullahsikandar

Board Regular
Joined
Feb 10, 2014
Messages
52

I need a help in a null validations on any cell

There are 5 rows and 5 columns, we have a button which checks for null values with respect to a specific column (here it should check with respect to ID and it shouldn`t leave any null values in the Date, Name, Age and the user should be able to give the null values for the cities.)​

What i need is that whenever i press the validtion button it will check all the filled columns and rows that they are filled with the data if there is any cell which is empty it will show up an error message that "Please enter the [column name]"

Thanks in Advance, I also attached my file for your consideration please help me.
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
[TABLE="width: 1031"]
<colgroup><col span="5"><col><col span="10"></colgroup><tbody>[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]id[/TD]
[TD]date[/TD]
[TD]name[/TD]
[TD]age[/TD]
[TD]city[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="align: right"]123[/TD]
[TD="align: right"]01/02/2014[/TD]
[TD]tom[/TD]
[TD="align: right"]25[/TD]
[TD]london[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="align: right"]234[/TD]
[TD="align: right"]03/02/2014[/TD]
[TD]fred[/TD]
[TD="align: right"]26[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD="colspan: 2"]this is acceptable?[/TD]
[TD][/TD]
[TD="align: right"]345[/TD]
[TD="align: right"]05/02/2014[/TD]
[TD]bill[/TD]
[TD="align: right"]27[/TD]
[TD]leeds[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="align: right"]456[/TD]
[TD="align: right"]07/02/2014[/TD]
[TD]harry[/TD]
[TD="align: right"]28[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="align: right"]567[/TD]
[TD="align: right"]09/02/2014[/TD]
[TD]david[/TD]
[TD="align: right"]29[/TD]
[TD]glasgow[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="colspan: 2"]on-screen message[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]id[/TD]
[TD]date[/TD]
[TD]name[/TD]
[TD]age[/TD]
[TD]city[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="align: right"]4[/TD]
[TD="colspan: 3"]fields need to be filled in[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="align: right"]01/02/2014[/TD]
[TD]tom[/TD]
[TD="align: right"]25[/TD]
[TD]london[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="align: right"]234[/TD]
[TD][/TD]
[TD]fred[/TD]
[TD="align: right"]26[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="align: right"]1[/TD]
[TD]id's[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD="colspan: 2"]this is as filled in[/TD]
[TD][/TD]
[TD="align: right"]345[/TD]
[TD="align: right"]05/02/2014[/TD]
[TD][/TD]
[TD="align: right"]27[/TD]
[TD]leeds[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="align: right"]1[/TD]
[TD]dates[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="align: right"]456[/TD]
[TD="align: right"]07/02/2014[/TD]
[TD]harry[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="align: right"]1[/TD]
[TD]names[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="align: right"]567[/TD]
[TD="align: right"]09/02/2014[/TD]
[TD]david[/TD]
[TD="align: right"]29[/TD]
[TD]glasgow[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="align: right"]1[/TD]
[TD]ages[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]does this approach seem helpful?[/TD]
[/TR]
</tbody>[/TABLE]
 
Upvote 0
Assuming the layout as:


Excel 2007
ABCDE
1iddatenameagecity
201/02/2014tom25london
3234fred26
434505/02/201427leeds
545607/02/2014harry
656709/02/2014david29glasgow
Sheet1


Try this in the ThisWorkbook module, not very elegant, but it works:
Rich (BB code):
Sub FillInBlanks()
   Dim rw As Long
   Dim col As Long
   Dim msg As String
   
   For rw = 2 To 6
      For col = 1 To 5
         
         With Sheets("Sheet1").Cells(rw, col)
            If .Value = "" Then
               msg = InputBox("Please Enter Row: " & rw & " " & Sheets("Sheet1").Cells(1, col).Value)
               .Value = msg
            End If
         End With
         
         msg = ""
      Next col
   Next rw
End Sub
 
Upvote 0
Set the Interior.ColorIndex:

Rich (BB code):
Sub FillInBlanks()
   Dim rw As Long
   Dim col As Long
   Dim msg As String
   
   For rw = 2 To 6
      For col = 1 To 5
         
         With Sheets("Sheet1").Cells(rw, col)
            If .Value = "" Then
                .Interior.ColorIndex = 3 'red
                
                
               'msg = InputBox("Please Enter Row: " & rw & " " & Sheets("Sheet1").Cells(1, col).Value)
               '.Value = msg
              
            End If
         End With
         
         msg = ""
      Next col
   Next rw
End Sub
 
Upvote 0
Awsome!!!!! :D ... Thanks ... bertie.. Last question what if i need to stop after showing the redcolor i mean there is some functionality after this and its not stopping after showing the red color.
 
Upvote 0
Hi, Bertie

I am attaching my code here, Can you review it and tell me where i am lacking because it always show up the message box and once i enter the value it will never stop, I want that once the mesgbox came up it will stop until the user press the save button again.


Private Sub btn_Save_Click()

Dim rw As Long
Dim col As Long
Dim msg As String

For rw = 2 To 6
For col = 1 To 5

With Sheets("Sheet1").Cells(rw, col)
If .Value = "" Then
.Interior.ColorIndex = 3 'red


msg = InputBox("Please Enter Row: " & rw & " " & Sheets("Sheet1").Cells(1, col).Value)
.Value = msg

End If
End With

msg = ""
Next col
Next rw
Dim Path As String
Dim FileName1 As String
Dim Date1 As String
Dim FileName2 As String
Path = "C:\Desktop"
formatted_time = Format(Now, "hh-mm")
formatted_date = Format(Now, "mm-dd-yyyy")
'MsgBox formatted_date
FileName1 = Range("B2")
FileName2 = Range("N2")
ActiveWorkbook.SaveAs Filename:=Path & formatted_date & ", " & formatted_time & ", " & FileName2 & ".xls", FileFormat:=xlNormal
MsgBox "File Saved on shared folder:-)"
ActiveWindow.Close
Dim lRow As Integer, Ans As String
lRow = 2

'Ans = MsgBox("Do you want to clear the data?", vbQuestion + vbYesNo, "Clear Data")
lRow = Sheets("EEA Referral Tracker").Range("A65536").End(xlUp).Row
If lRow > 1 Then
Range("A2:AG" & lRow).Delete
End If

' Dim SaveCommonFile As String
'Path = "C:\Users\xf37\Desktop\RCO Referrals"
'ActiveWorkbook.SaveAs Filename:=Path & ".xls", FileFormat:=xlNormal


End Sub
 
Upvote 0

Forum statistics

Threads
1,224,884
Messages
6,181,564
Members
453,053
Latest member
Kiranm13

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top