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

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
iddatenameagecity
12301/02/2014tom25london
23403/02/2014fred26
this is acceptable?34505/02/2014bill27leeds
45607/02/2014harry28
56709/02/2014david29glasgow
on-screen message
iddatenameagecity4fields need to be filled in
01/02/2014tom25london
234fred261id's
this is as filled in34505/02/201427leeds1dates
45607/02/2014harry1names
56709/02/2014david29glasgow1ages
does this approach seem helpful?

<colgroup><col span="5"><col><col span="10"></colgroup><tbody>
</tbody>
 
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
Thanks for your help.. This is working fine but instead of mesg box what if i want to highlight the missing cells using a color??
 
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,215,063
Messages
6,122,935
Members
449,094
Latest member
teemeren

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