Notifications
Clear all

Macro ocultar /exibir

6 Posts
1 Usuários
0 Reactions
1,960 Visualizações
(@fernandofernandes)
Posts: 43750
Illustrious Member
Topic starter
 

Como faço para que ao clicar em um botão a macro veja se um determinado espaço está visivel e oculte , se está oculto exiba.

EXemplo:

Planilha 1
botão OCULTAR_EXIBIR
se da linha 1 a linha 12 estiver oculta
clicando em OCULTAR_EXIBIR - mande exibir da linha 1 a 12

se da linha 1 a linha 12 estiver visivel
clicando em OCULTAR_EXIBIR - mande ocultar da linha 1 a 12

 
Postado : 31/01/2012 5:20 am
(@fernandofernandes)
Posts: 43750
Illustrious Member
Topic starter
 

claudinei, veja se é isto :

Sub VerificaLinhaOculta()
    Dim Rng As Range
  
    Set Rng = Range("A1:A12")

    If Rng.EntireRow.Hidden = True Then
        MsgBox "Oculta"
        Rng.EntireRow.Hidden = False
    Else
        MsgBox "Não culta"
        Rng.EntireRow.Hidden = True
    End If

End Sub

[]s

 
Postado : 31/01/2012 5:42 am
(@fernandofernandes)
Posts: 43750
Illustrious Member
Topic starter
 

Bom dia!!!

Veja um exemplo ..

Fonte:VBA express

ption Explicit 
 
Private Sub Worksheet_Activate() 
     
    Dim HiddenRow&, RowRange As Range, RowRangeValue& 
     
     '**************************
     '< Set the 1st & last rows to be hidden >
    Const FirstRow As Long = 4 
    Const LastRow As Long = 20 
     
     '< Set the columns that may contain data >
    Const FirstCol As String = "B" 
    Const LastCol As String = "G" 
     '**************************
     
    ActiveWindow.DisplayZeros = False 
    Application.ScreenUpdating = False 
     
    For HiddenRow = FirstRow To LastRow 
         
         '(we're using columns B to G here)
        Set RowRange = Range(FirstCol & HiddenRow & _ 
        ":" & LastCol & HiddenRow) 
         
         'sums the entries in cells in the RowRange
        RowRangeValue = Application.Sum(RowRange.Value) 
         
        If RowRangeValue <> 0 Then 
             'there's something in this row - don't hide
            Rows(HiddenRow).EntireRow.Hidden = False 
        Else 
             'there's nothing in this row yet - hide it
            Rows(HiddenRow).EntireRow.Hidden = True 
        End If 
         
    Next HiddenRow 
     
    Application.ScreenUpdating = True 
     
End Sub 
 
 
Postado : 31/01/2012 5:43 am
(@fernandofernandes)
Posts: 43750
Illustrious Member
Topic starter
 

Matou a pau , valeu Mauro e Alexandre.

Abusando de vcs vou postar mais uma duvida.

 
Postado : 31/01/2012 5:55 am
(@fernandofernandes)
Posts: 43750
Illustrious Member
Topic starter
 

Boa notie,

como eu consigo visualizar o resultado desse código fonte que voces disponibilizam?

Eu copiei e colei no VBA. E depois faz oq?

 
Postado : 29/07/2012 3:36 pm
(@fernandofernandes)
Posts: 43750
Illustrious Member
Topic starter
 

Boa noite!!

Seja bem vindo!!

Use a tecla F5, se o editor estiver aberto.

Caso contrario use um botão de comando, na guia desenvolvedor

Para habilitar a guia:
http://guiadoexcel.com.br/habilitando-a ... a-internet

Para executar através de um botão de comando
http://office.microsoft.com/pt-br/excel ... 36676.aspx
Att

 
Postado : 29/07/2012 3:42 pm