MSexcel: Difference between revisions

From wiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
(One intermediate revision by the same user not shown)
Line 12: Line 12:
The VLOOKUP formula above sets an empty string if there is no value in the lookup-range (A2:B10). To make these cells really empty create and execute a macro like:
The VLOOKUP formula above sets an empty string if there is no value in the lookup-range (A2:B10). To make these cells really empty create and execute a macro like:


<syntaxhighlight lang='VBScript'>
<syntaxhighlight lang=vbnet>
Sub EmptyCells()
Sub EmptyCells()
'
'
Line 18: Line 18:
'
'
'
'
     For Each cell In Range("C2:D10)
     For Each cell In Range("C2:D10")
         If (cell.Value = "") Then cell.ClearContents
         If (cell.Value = "") Then cell.ClearContents
     Next
     Next
End Sub
End Sub
</syntaxhighlight>
</syntaxhighlight>

Latest revision as of 09:56, 6 May 2020

Some formula's to remember if you have to use Excel

TEKST(A1,"00000")
Fill out the value of cell A1 with 0's on the left side.
TEKST(2,"0000") => 0002
=IF(LEN(VLOOKUP(D2,A2:B10,2,0))=0,"",VLOOKUP(D2,A2:B10,2,0))
VLOOKUP returns 0 values for empty cells by default. This looks better.


Clear cells with empty string

The VLOOKUP formula above sets an empty string if there is no value in the lookup-range (A2:B10). To make these cells really empty create and execute a macro like:

Sub EmptyCells()
'
' EmptyCells Macro
'
'
    For Each cell In Range("C2:D10")
        If (cell.Value = "") Then cell.ClearContents
    Next
End Sub