I have posted the following in this forum in the link given below.
Since, SOLVED is mentioned in the caption, I am not getting any reply from Experts. hence I amposting my two queries again here. Please reply.
https://www.mrexcel.com/forum/excel...er-explanation-null-empty-nothing-solved.html
................. .............. .............. .........
Kindly explain the fault in my code given below. Though DOUBLE QUOTES
is assigned to variable, IsEmpty returns FALSE. Why?
................. .............. .............. .........
Excel Experts, Kindly suggest me which code to use to find whether a cell is blank in an used range.
Thanks in advance for the suggestions of any expert.
Since, SOLVED is mentioned in the caption, I am not getting any reply from Experts. hence I amposting my two queries again here. Please reply.
https://www.mrexcel.com/forum/excel...er-explanation-null-empty-nothing-solved.html
................. .............. .............. .........
Kindly explain the fault in my code given below. Though DOUBLE QUOTES
is assigned to variable, IsEmpty returns FALSE. Why?
Code:
Private sub DoubleQuotesChckr
Dim varMyValue As Variant
Dim bEmptyCheck As Boolean
varMyValue = ""
bEmptyCheck = IsEmpty(varMyValue)
If varMyValue = "" Then
MsgBox "Double Quotes is assigned to var." & vbCrLf & _
"Var value is Double Quotes" & vbCrLf & _
"Empty status := " & bEmptyCheck
Else
MsgBox "Double Quotes is assigned to var." & vbCrLf & _
"Var value is NOT Double Quotes" & vbCrLf & _
"Empty status := " & bEmptyCheck
End If
End Sub
Excel Experts, Kindly suggest me which code to use to find whether a cell is blank in an used range.
Code:
Private Sub WhichEmptyDoubleQuotesNothingEntered()
'Which code to use to check if a cell is blank?
Dim AsoNo As Range
Dim bEmptyCheck As Boolean
Sheets("Sheet1").Select
Range("A10").Value = ""
Set AsoNo = Range("A10")
If Application.CountA(AsoNo) <> 0 Then
MsgBox "Range 10 has double quotes.[" & Range("A10").Value & "]" & vbCrLf & _
"CountA(AsoNo) is not zero = " & Application.CountA(AsoNo)
Else
MsgBox "Range 10 has double quotes.[" & Range("A10").Value & "]" & vbCrLf & _
"CountA(AsoNo) gets zero = " & Application.CountA(AsoNo)
End If
MsgBox "range a20=[" & Range("a20").Value & "]" 'blank in used range in sheet1
If Application.CountA(AsoNo) <> 0 Then
MsgBox "Range 20 is blank in used range.[" & Range("A20").Value & "]" & vbCrLf & _
"CountA(AsoNo) not zero = " & Application.CountA(AsoNo)
Else
MsgBox "Range 20 is blank in used range.[" & Range("A20").Value & "]" & vbCrLf & _
"CountA(AsoNo) gets zero = " & Application.CountA(AsoNo)
End If
If Trim(AsoNo.Value) = "" Then 'YES
MsgBox "IF. AsoNo = Range 10 is double quotes.[" & Range("A10").Value & "]"
Else
MsgBox "ELSE. AsoNo = Range 10 is double quotes.[" & Range("A10").Value & "]"
End If
If Trim(Range("a20").Value) = "" Then 'YES
MsgBox "IF. Range 20 is not used.[" & Range("A20").Value & "]"
Else
MsgBox "ELSE. Range 20 is not used.[" & Range("A20").Value & "]"
End If
Range("A10").Value = ""
bEmptyCheck = IsEmpty(Range("A10").Value)
If bEmptyCheck = True Then 'YES
MsgBox "Range is double quotes. So, blank." & vbCrLf & _
"Empty status := " & bEmptyCheck
bEmptyCheck = False
Else
MsgBox "Range is double quotes. So, not blank." & vbCrLf & _
"Empty status := " & bEmptyCheck
End If
Range("A10").Value = ""
Range("A10").Value = Trim(Range("A10").Value)
bEmptyCheck = IsEmpty(Range("A10").Value)
If bEmptyCheck = True Then 'YES
MsgBox "Range has double quotes & also Trimmed.[" & _
Range("A10").Value & "]" & vbCrLf & _
"IsEmpty is TRUE." & vbCrLf & _
"Empty status := " & bEmptyCheck
bEmptyCheck = False
Else
MsgBox "Range has double quotes & Trimmed.[" & _
Range("A10").Value & "]" & vbCrLf & _
"IsEmpty is FALSE." & vbCrLf & _
"Empty status := " & bEmptyCheck
End If
AsoNo.Value = ""
AsoNo.Value = Trim(AsoNo.Value)
bEmptyCheck = IsEmpty(AsoNo.Value)
If bEmptyCheck = True Then 'YES
MsgBox "Range has double quotes & also Trimmed.[" & _
AsoNo.Value & "]" & vbCrLf & _
"IsEmpty is TRUE." & vbCrLf & _
"Empty status := " & bEmptyCheck
bEmptyCheck = False
Else
MsgBox "Range has double quotes & Trimmed.[" & _
AsoNo.Value & "]" & vbCrLf & _
"IsEmpty is FALSE." & vbCrLf & _
"Empty status := " & bEmptyCheck
End If
AsoNo.Value = "TEXT "
AsoNo.Value = Trim(AsoNo.Value)
bEmptyCheck = IsEmpty(AsoNo.Value)
If bEmptyCheck = True Then 'YES
MsgBox "Range has a string & also Trimmed.[" & _
AsoNo.Value & "]" & vbCrLf & _
"IsEmpty is TRUE." & vbCrLf & _
"Empty status := " & bEmptyCheck
bEmptyCheck = False
Else
MsgBox "Range has a string & Trimmed.[" & _
AsoNo.Value & "]" & vbCrLf & _
"IsEmpty is FALSE." & vbCrLf & _
"Empty status := " & bEmptyCheck
End If
AsoNo.Value = "TEXT "
bEmptyCheck = IsEmpty(Trim(AsoNo.Value))
If bEmptyCheck = True Then 'YES
MsgBox "Range has a string & also Trimmed.[" & _
AsoNo.Value & "]" & vbCrLf & _
"IsEmpty is TRUE." & vbCrLf & _
"Empty status := " & bEmptyCheck
bEmptyCheck = False
Else
MsgBox "Range has a string & Trimmed.[" & _
AsoNo.Value & "]" & vbCrLf & _
"IsEmpty is FALSE." & vbCrLf & _
"Empty status := " & bEmptyCheck
End If
End Sub