Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Excel Sheet Validation

Hello !!

I have requirement to validate for Null value in excel sheet. Below
code is used in one of my application (Which compares Column A & B
entry. As of now, it validates for A Column <= Column B), but fails to
validate for Null, which is creating problem. I have tried by setting
IgnoreBlank = False, but no success. Please help me out !! to validate
for Null value as well in either Column A 0r B.

Private Sub Workbook_Open()
Dim intCnt As Integer
Dim intTotal As Integer
intTotal = 10

For intCnt = 1 To intTotal
Range("A" & intCnt).Select

With Selection.Validation
.Delete
.Add Type:=xlValidateWholeNumber,
AlertStyle:=xlValidAlertStop, _
Operator:=xlBetween, Formula1:="0", Formula2:="=B" &
intCnt
.IgnoreBlank = True
.InCellDropdown = False
.ErrorTitle = "A Vs B Qty Error"
.ErrorMessage = "A Quantity cannot be greater than B
Quantity."
.ShowInput = True
.ShowError = True
End With

Next
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Excel Sheet Validation


VBA has two functions ISEMPTY() and ISNULL(). Add a test

if ISNULL(Selection ) = true then

"raajkul" wrote:

Hello !!

I have requirement to validate for Null value in excel sheet. Below
code is used in one of my application (Which compares Column A & B
entry. As of now, it validates for A Column <= Column B), but fails to
validate for Null, which is creating problem. I have tried by setting
IgnoreBlank = False, but no success. Please help me out !! to validate
for Null value as well in either Column A 0r B.

Private Sub Workbook_Open()
Dim intCnt As Integer
Dim intTotal As Integer
intTotal = 10

For intCnt = 1 To intTotal
Range("A" & intCnt).Select

With Selection.Validation
.Delete
.Add Type:=xlValidateWholeNumber,
AlertStyle:=xlValidAlertStop, _
Operator:=xlBetween, Formula1:="0", Formula2:="=B" &
intCnt
.IgnoreBlank = True
.InCellDropdown = False
.ErrorTitle = "A Vs B Qty Error"
.ErrorMessage = "A Quantity cannot be greater than B
Quantity."
.ShowInput = True
.ShowError = True
End With

Next
End Sub


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Excel Sheet Validation

If you are trying to force a user to make an entry in a cell, there is no
form of data validation that will do that.

--
Regards,
Tom Ogilvy


"raajkul" wrote:

Hello !!

I have requirement to validate for Null value in excel sheet. Below
code is used in one of my application (Which compares Column A & B
entry. As of now, it validates for A Column <= Column B), but fails to
validate for Null, which is creating problem. I have tried by setting
IgnoreBlank = False, but no success. Please help me out !! to validate
for Null value as well in either Column A 0r B.

Private Sub Workbook_Open()
Dim intCnt As Integer
Dim intTotal As Integer
intTotal = 10

For intCnt = 1 To intTotal
Range("A" & intCnt).Select

With Selection.Validation
.Delete
.Add Type:=xlValidateWholeNumber,
AlertStyle:=xlValidAlertStop, _
Operator:=xlBetween, Formula1:="0", Formula2:="=B" &
intCnt
.IgnoreBlank = True
.InCellDropdown = False
.ErrorTitle = "A Vs B Qty Error"
.ErrorMessage = "A Quantity cannot be greater than B
Quantity."
.ShowInput = True
.ShowError = True
End With

Next
End Sub


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Excel Sheet Validation

IsNULL is useless for checking if a cell is empty or not. Isempty is the
correct check.

--
Regards,
Tom Ogilvy


"Joel" wrote:


VBA has two functions ISEMPTY() and ISNULL(). Add a test

if ISNULL(Selection ) = true then

"raajkul" wrote:

Hello !!

I have requirement to validate for Null value in excel sheet. Below
code is used in one of my application (Which compares Column A & B
entry. As of now, it validates for A Column <= Column B), but fails to
validate for Null, which is creating problem. I have tried by setting
IgnoreBlank = False, but no success. Please help me out !! to validate
for Null value as well in either Column A 0r B.

Private Sub Workbook_Open()
Dim intCnt As Integer
Dim intTotal As Integer
intTotal = 10

For intCnt = 1 To intTotal
Range("A" & intCnt).Select

With Selection.Validation
.Delete
.Add Type:=xlValidateWholeNumber,
AlertStyle:=xlValidAlertStop, _
Operator:=xlBetween, Formula1:="0", Formula2:="=B" &
intCnt
.IgnoreBlank = True
.InCellDropdown = False
.ErrorTitle = "A Vs B Qty Error"
.ErrorMessage = "A Quantity cannot be greater than B
Quantity."
.ShowInput = True
.ShowError = True
End With

Next
End Sub


Reply
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
Data Validation in another sheet Aligahk06 Excel Discussion (Misc queries) 1 September 30th 09 09:17 AM
[err] Excel 2007 - Data validation from another sheet? Jon Excel Discussion (Misc queries) 1 April 10th 09 03:30 PM
Excel sheet validation Renjith R Excel Discussion (Misc queries) 1 August 21st 07 02:00 PM
Dat Validation Different Sheet RigasMinho Excel Programming 7 August 4th 06 07:43 PM
Validation from another sheet Derek Witcher[_2_] Excel Programming 1 September 17th 04 02:20 AM


All times are GMT +1. The time now is 04:23 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"