Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

140
Views
VBA sub no selecciona el rango de una hoja de trabajo específica

Solo quiero obtener el rango de A1: A80 de una hoja llamada "Niños", pero lo depuré, no obtiene nada. Aquí está mi código a continuación:

 Dim wks2 As Worksheet Dim children As Range Worksheets("Children").Activate Set wks2 = Worksheets("Children") Set children = wks2.Range("A1:A80") ResetChild (children) //The sub that I want to call. Explanation bellow.

En la función ResetChild, quiero eliminar todas las hojas de mi Workbook, que tienen nombres iguales a la primera columna de la hoja Children. (A1: A80) Así que aquí está mi sub a continuación:

 Sub ResetChild(children As Range) Call DisableCalculations Dim cell As Range For Each cell In children Set childrenSheet = Worksheets(cell.Value) If (DoesSheetExist(childrenSheet)) Then Application.DisplayAlerts = False Sheets(childrenSheet).Delete Application.DisplayAlerts = True End If End Sub
about 4 years ago · Santiago Trujillo
2 answers
Answer question

0

Tu código debería funcionar. ¿Cómo sabes que no devuelve nada? pon la fila al final de tu código

 Debug.Print children.Count

si devuelve> 0, entonces todo está bien y los niños son el objeto de rango con datos

about 4 years ago · Santiago Trujillo Report

0

Tal vez intente algo como esto:

 Sub DeleteChildren() Dim children As Range Dim oChildSheet As Worksheet Dim vChildName Set children = ThisWorkbook.Worksheets("Children").Range("A1:A80") For Each vChildName In children Set oChildSheet = GetChildSheet(CStr(vChildName)) If Not oChildSheet Is Nothing Then Application.DisplayAlerts = False Call oChildSheet.Delete Application.DisplayAlerts = True End If Next vChildName End Sub Function GetChildSheet(sChildName As String) As Worksheet On Error GoTo errHandler Set GetChildSheet = ThisWorkbook.Worksheets(sChildName) Exit Function errHandler: Debug.Print "Child sheet not found: " & sChildName End Function
about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!