Notifications
Clear all

Ajuda VBA

3 Posts
2 Usuários
0 Reactions
832 Visualizações
(@miguel-70)
Posts: 207
Estimable Member
Topic starter
 

Óla pessoal,
quero usar esta macro em varias plan's, somente não pode interferir nas plan's listadas na coluna M entre ("M8:M100"), como faço para arrumar este código?

Sub Ocultar_Plan_Listadas()
On Error Resume Next
  Dim ws As Excel.Worksheet
  For Each ws In ThisWorkbook.Worksheets
    Select Case ws.Name
    
      Case Plan1.Range("M8") '("M8:M100")
      Case Plan1.Range("M9")
      
      Case Else
        Verificar_Data ws
    End Select
  Next ws
End Sub
Sub Verificar_Data(ws As Excel.Worksheet)
ws.Activate
Range("B10") = "ocultar"
Plan1.Select
End Sub

Obrigado.

 
Postado : 13/12/2014 5:06 pm
Fernando Fernandes
(@fernandofernandes)
Posts: 43750
Illustrious Member
 

Eu faria assim:

Option Explicit

Sub Ocultar_Plan_Listadas_FF()
On Error Resume Next
Dim wsf As Excel.WorksheetFunction
Dim ws  As Excel.Worksheet
    
    Set wsf = Excel.WorksheetFunction
    For Each ws In ThisWorkbook.Worksheets
    
        If ws.Name <> Plan1.Name Then
            If wsf.CountIf(Plan1.Range("M:M"), ws.Name) = 0 Then
                Verificar_Data ws
            End If
        End If
        
    Next ws
    
    Set ws = Nothing
    Set wsf = Nothing
End Sub

Sub Verificar_Data(ws As Excel.Worksheet)
  ws.Range("B10").Value = "ocultar"
End Sub

Existem mil maneiras de preparar Neston. Invente a sua!
http://www.youtube.com/ExpressoExcel

 
Postado : 13/12/2014 6:22 pm
(@miguel-70)
Posts: 207
Estimable Member
Topic starter
 

Maravilha!!!!!!!!
Obrigado fernando.fernandes

 
Postado : 13/12/2014 6:47 pm