Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

184
Visualizações
Excel VBA Macro Crashes Excel

I have created a macro with some help with the wonderful people of this website that figures out if columns in this excel are filled and then separates them for a bigger project. my problem is that the code just crashes (loads until I click in which I'm told excel is unresponsive) excel. could I get some help

Option Explicit

Public Sub emptysinder()

    Dim i As Long
    Dim r As Range
    Dim num As Integer
    
    For i = 1 To 9
        Set r = Range("F1").Offset(0, i - 1).Resize(200, 1)
        If IsAllEmpty(r) Then
            num = num + 1
            Debug.Print "Range " & r.Address & " is all empty." & num
        ElseIf IsAnyEmpty(r) Then
            Debug.Print "Range " & r.Address & " is partially empty."
        Else
            Debug.Print "Range " & r.Address & " filled."
        End If
    Next i
    split (num)

End Sub

Public Function IsAllEmpty(ByVal r_range As Range) As Boolean
    Dim Item As Range
    For Each Item In r_range
        If Not IsEmpty(Item) Then
            IsAllEmpty = False
            Exit Function
        End If
    Next
    IsAllEmpty = True
End Function

Public Function IsAnyEmpty(ByVal r_range As Range) As Boolean
    Dim Item As Range
    For Each Item In r_range
        If IsEmpty(Item) Then
            IsAnyEmpty = True
            Exit Function
        End If
    Next
    IsAnyEmpty = False
End Function
Public Function split(i As Integer)
    Dim sheet As Integer
    Dim colOpt As Integer
    sheet = 14
    colOpt = sheet - i
    Dim s As Integer
    Do While i > 0
        For s = 4 To 0
        Columns(colOpt).Select
        Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
        i = i - 1
        Next s
    Loop
End Function
about 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

As Shrotter said above, your for loop in the split function isn't executing because the s value is incrementing, not decrementing. Use For s = 4 To 0 Step -1 to decrease s by 1 every iteration.

about 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda