Estou usando o Excel 2013. Sou novo no VBA. Encontrei um código que simplesmente ocultaria 2 linhas (36 e 37) se meu celular N39 fosse igual a "Aprovado"
Encontrei esse código, mas recebo a mensagem "nome ambíguo detectado" Alteração da planilha "
Private Sub Worksheet_Change(ByVal Target As Range)
If Range("N39").Value = "Passed" Then
Rows("36:37").EntireRow.Hidden = True
ElseIf Range("N39").Value = "Failed" Then
Rows("36:37").EntireRow.Hidden = False
End If
End Sub
então eu tentei o nome da minha planilha, mas não faz nada
Private Sub NRF(ByVal Target As Range)
If Range("N39").Value = "Passed" Then
Rows("36:37").EntireRow.Hidden = True
ElseIf Range("N39").Value = "Failed" Then
Rows("36:37").EntireRow.Hidden = False
End If
End Sub
Poderia ser porque eu tenho outro código acima?
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Dim celltxt As String
celltxt = ActiveSheet.Range("E39").Text
If InStr(1, celltxt, "P670-Staffing") Then
MsgBox "Add the job title and type of hire in the description cell - column H" & vbNewLine & vbNewLine & "If this is a new position, please obtain your HRBP's approval"
End If
End Sub
Alguma idéia do que estou fazendo de errado?
Worksheet_Change
NRF
. Worksheet_Change
é uma função de evento chamada pelo Excel quando a planilha é alterada. Você precisa colocar todo o código dentro #Worksheet_Change