Yesterday I thought I understood isblank, but I was wrong.
Today I am 100% sure I really really understand it which means I'm sure to be wrong again.
Will someone just check this out and see if there are any glaring errors?
When cutting peoples names from a web page and pasting into excel, the result often has blanks at the end of the text.
I always fix this up by trimming the names.
To illustrate this, type the following into these cells
a1 John Doe
a2 John Doe (followed by 5 blanks)
a3 (don't type anything, leave it blank)
a4 x
a5 x
c1 = len(a1)
copy c1 and paste in c1:d5
e1 = IF(ISBLANK(A1),CELL("addre
ss",A1)&"I
SBLANK",""
)
copy e1 and paste in e1:f5
You will see that len(a2) is 13 because of the 5 blanks
I usually fix this by
inserting =trim(a1) into cell b1,
dragging b1 to b5
copy b1:b5 to clipboard
paste > special > values into a1:a5
I thought this was perfect, but (alas) i was wrong.
Notice that a3, which started out IS BLANK, is no longer blank.
Also notice a3 still is length 0.
finally notice that selecting a1 then doing a ctrl down arrow does not stop at the first blank cell, because it is not really blank.
You can repeat this by selecting a3 and hitting the delete key on keyboard.
Question #1 can I fix this without resorting to vba? (I tried =IF(ISBLANK(A3),"",TRIM(A3
))) but the cut and paste didn't work.
Question #2 is there a way of telling Excel to automatically delete trailing blanks from every data entry, import, or cut and paste?
Question #3 I believe that worksheet function ISBLANK is 100% equivalent to vba function ISEMPTY. In other words, Bill Gates simply misnamed it. Am I correct, or is there something subtle that I am missing?
Question #4 I believe that the following vba line accomplish exactly the same thing. Am I missing something subtle?
mycell.formula = ""
mycell.formula = null
rberke
p.s. --------------------------
----------
----------
--
To fix this, I have resorted to the following, but i don't like it because it resets the Undo chain. I use Undo a lot, especially when I am cutting and pasting this junk.
sub myChangeToValue()
for each cl in selection.cells
cl.value = rtrim(cl.value)
next cl
end sub