Saltar al contenido

cómo verificar si la celda está vacía ejemplo de código vba

Ejemplo 1: excel vba cómo verificar si una celda de la hoja de trabajo está vacía

'VBA to check if cell A1 is blank.

'The best way:
MsgBox IsEmpty([A1])
'But if a formula that returns a zero-length string is in A1, 
'IsEmpty() will return False.


'Another way:
MsgBox Len([A1]) = 0
'Len() will report 0 if A1 contains a formula that returns a
'zero-length string or is completely empty.

'But IsEmpty() is usually better because Len() will throw an
'error if there is an error value in the cell. IsEmpty() on the 
'other hand will just gracefully report False.

'The worksheet functions COUNT() and COUNTA() can also be utilized.
'But these require a call through the boundary between VBA and 
'Excel, which can be slow if done within a loop.

Ejemplo 2: celda de verificación de Excel vba no está vacía

'VBA to check if cell A1 has a value.

'Two different ways...

MsgBox Not IsEmpty([A1])

MsgBox Not Len([A1]) = 0
¡Haz clic para puntuar esta entrada!
(Votos: 0 Promedio: 0)


Tags : /

Utiliza Nuestro Buscador

Deja una respuesta

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *