Notifications
Clear all

AJUSTAR MACRO

4 Posts
2 Usuários
0 Reactions
1,076 Visualizações
 Vkt
(@vkt)
Posts: 33
Eminent Member
Topic starter
 

Bom dia pessoal,

Preciso ajustar a seguinte macro:

Sub REEXIBEEJANSED()
    Application.ScreenUpdating = False
    For Each myCell In Sheets("JANSED").Range("D18:D45")
        If myCell = "" Then
            myCell.EntireRow.Hidden = False
        End If
    Next myCell
    For Each xChkBox In ActiveSheet.CheckBoxes
        xChkBox.Visible = True
    Next
    Application.ScreenUpdating = True
End Sub

Gostaria que o xChkBox respeitasse o mesmo Range("D18:D45").

Da forma como está, a macro deixa visíveis/ocultas todas as checkboxes da planilha.

É possível?

 
Postado : 06/09/2018 7:24 am
Wagner Morel
(@wagner-morel-vidal-nobre)
Posts: 0
Illustrious Member
 

Vkt,

Bom dia!

Tente assim:

Sub REEXIBEEJANSED()
    Application.ScreenUpdating = False
    For Each myCell In Sheets("JANSED").Range("D18:D45")
        If myCell = "" Then
            myCell.EntireRow.Hidden = False
            For Each xChkBox In ActiveSheet.CheckBoxes
                xChkBox.Visible = True
           Next
        End If
    Next myCell
    Application.ScreenUpdating = True
End Sub

Desenvolvo pequenas soluções em VBA Excel a valores que variam entre R$ 50,00 a R$ 200,00. Se te interessar, entre no meu instagran (vba_excel_desenvolvimento)

Atenciosamente
Wagner Morel

 
Postado : 06/09/2018 7:37 am
 Vkt
(@vkt)
Posts: 33
Eminent Member
Topic starter
 

Wagner,

Continua ocultando/reexibindo todas as checkboxes.

 
Postado : 06/09/2018 9:15 am
 Vkt
(@vkt)
Posts: 33
Eminent Member
Topic starter
 

Olá pessoal,

A quem interessar, eu encontrei uma solução:

Sub OCULTAJANSED()
    Dim xChkBox As CheckBox
    Application.ScreenUpdating = False
    For Each myCell In Sheets("JANSED").Range("D18:D45")
        If myCell = "" Then
            myCell.EntireRow.Hidden = True
        End If
    Next myCell
    For Each Chk In ActiveSheet.CheckBoxes
        If Not Intersect(Chk.TopLeftCell, Range("18:45")) Is Nothing Then
            With Chk
                .Visible = Not .Visible
            End With
        End If
    Next Chk
    Application.ScreenUpdating = True
End Sub
Sub REEXIBEEJANSED()
    Application.ScreenUpdating = False
    For Each myCell In Sheets("JANSED").Range("D18:D45")
        If myCell = "" Then
            myCell.EntireRow.Hidden = False
        End If
    Next myCell
    For Each Chk In ActiveSheet.CheckBoxes
        If Not Intersect(Chk.TopLeftCell, Range("18:45")) Is Nothing Then
            With Chk
                .Visible = Not xHide
            End With
        End If
    Next Chk
    Application.ScreenUpdating = True
End Sub
Sub OCULTAPAG1()
    Application.ScreenUpdating = False
    Set pagina1 = Range("2:55"): Set pagina2 = Range("56:109")
    pagina1.EntireRow.Hidden = True: pagina2.EntireRow.Hidden = False
    For Each Chk In ActiveSheet.CheckBoxes
        If Not Intersect(Chk.TopLeftCell, Range("2:55")) Is Nothing Then
            With Chk
                .Visible = Not .Visible
            End With
        ElseIf Not Intersect(Chk.TopLeftCell, Range("56:109")) Is Nothing Then
            With Chk
                .Visible = Not xHide
            End With
        End If
        Next Chk
    Application.ScreenUpdating = True
End Sub

Em todos os casos as checkboxes são ocultadas e reexibidas num range específico.

 
Postado : 09/09/2018 11:07 am