top of page
Buscar

Método para saber si existe un objeto EXCEL

  • Foto del escritor: Carlos Cerrato
    Carlos Cerrato
  • 27 feb 2016
  • 1 Min. de lectura

Lo normal para saber si existe una hoja es hacer un bucle preguntando por la propiedad nombre.

Este método es mejor, más rápido y claro. Se trata de crear ("SET") un objeto y preguntar sobre su existencia. Veamos..

Sub VerificarWorkSheet()

Dim ReportSheet As Worksheet

On Error Resume Next

Set ReportSheet = Sheets("Nombre Prueba")

Application.DisplayAlerts = False

If ReportSheet Is Nothing Then

Worksheets.Add.Name = "Hoja Prueba"

End If

End Sub

Comments


Entradas destacadas
Entradas recientes
Archivo
Buscar por tags
Síguenos
  • Facebook Basic Square
  • Twitter Basic Square
  • Google+ Basic Square
bottom of page