Conditional formatting - isblank option

UHsoccer

Well-known Member
Joined
Apr 3, 2002
Messages
1,023
When a cell is empty, the "isblank(A1)" formula works fine.
But
If I enter a number of spaces, the formaula 1 (isblank) fails.

Here are my curent condtions

1) Formula - =IsBlank(J3) then background Yellow

2) Cell Value is - not equal to - =("OK") then Red

3) Cell Value is - equal to - ="OK" then Green
 
I copied your solution (from Report) and it stays red for NO-blanks or any number of blanks for that matter. it seemed to ignore the condition.

Amazing that such a simple concept as "If a cell APPEARS to be empty, then..." can get so difficult.

Also the TRIM function did not do

Nor the IfCellIsBlank Function

I am close to resurecting my old resume and go back to ......

Just the same, it is a great forum.
 
Upvote 0

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Hey,
OK, found the problem with the IfCellIsBlank function, just a minor spelling error, but the code works fine on my machine.

If Len(ActiveCell.Text) = 0 or IfCellIsBlank(ActiveCell.text) = True Then
'code to format cell to Yellow
Elseif ActiveCell.Text = "OK" Then
'code to format cell to Green
Else
'code to format cell to Red.
End if


Function IfCellIsBlank(strText As String) As Boolean



For i = 1 To Len(strText)
If Mid(strText, i, 1) <> " " Then
IfCellIsBlanks = False
Exit Function
End If
Next

IfCellIsBlank = True

End Function
 
Upvote 0
north19701 said:
this is is for condition yellow.
=LEN(J3)-LEN(SUBSTITUTE(J3," ",""))=LEN(J3)

=LEN(J3)=LEN(SUBSTITUTE(J3," ",""))

would be shorter. In fact, much shorter:

=TRIM(J3)=""
 
Upvote 0
Sorry, one more change, the IfCellIsBlanks below should be IfCellIsBlank (no "s") at the end.

Yesuslave said:
For i = 1 To Len(strText)
If Mid(strText, i, 1) <> " " Then
IfCellIsBlanks = False
Exit Function
End If
Next

IfCellIsBlank = True

End Function
 
Upvote 0
UHsoccer said:
When a cell is empty, the "isblank(A1)" formula works fine.
But
If I enter a number of spaces, the formaula 1 (isblank) fails.

Here are my curent condtions

1) Formula - =IsBlank(J3) then background Yellow

2) Cell Value is - not equal to - =("OK") then Red

3) Cell Value is - equal to - ="OK" then Green

Try:

1)

=TRIM(J3)="" for yellow.

2)

=(TRIM(J3)<>"")*(J3<>"OK") for red.

3)

=J3="OK" for green.
 
Upvote 0

Forum statistics

Threads
1,214,631
Messages
6,120,645
Members
448,974
Latest member
DumbFinanceBro

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