PROBLEMAS COM IF

 Tópico anterior Próximo tópico Novo tópico

PROBLEMAS COM IF

VB / VBA

 Compartilhe  Compartilhe  Compartilhe
#356277 - 29/10/2010 15:00:11

MARCELGARCIA
MACAE
Cadast. em:Outubro/2010


Senhores, estou com um problema no seguinte bloco:

Citação:
  Sub WellPlanCheck_Show()
  If wellcheck = True Then
   Rows([Ô]19:27[Ô]).Select
   Selection.Rows.Hidden = True
  Else
   Rows([Ô]18:28[Ô]).Select
   Selection.Rows.Hidden = False
  End If
End Sub  


Esse bloco eh para exibir/ocultar determinadas linhas, o wellcheck que está no IF é um checkbox que possui este nome, porém independente de qualquer valor que eu coloque no checkbox ele sempre executa o Else. Ou seja: ele não esconde as celulas, soh mostra... alquem sabe como solucionar isso?

Abs

_________________________________________
Marcel Garcia

#356279 - 29/10/2010 15:15:08

SACOFRITO
SP
Cadast. em:Janeiro/2010


pro check box vc usa 1 para true e 0 para false


Seguindo em frente.

#356280 - 29/10/2010 15:25:36

MARCELGARCIA
MACAE
Cadast. em:Outubro/2010


Citação:
:
pro check box vc usa 1 para true e 0 para false


Independente disso, ele continua executando somente o else...

Mas grato msm assim!

_________________________________________
Marcel Garcia

#356284 - 29/10/2010 15:38:34

LUIZCOMINO
SAO PAULO
Cadast. em:Maio/2009


tenta inverter assim

  Sub WellPlanCheck_Show()
  If wellcheck = True Then
   Rows([Ô]18:28[Ô]).Select
   Selection.Rows.Hidden = False
  Else
   Rows([Ô]19:27[Ô]).Select
   Selection.Rows.Hidden = True
  End If
End Sub  


ou

Sub WellPlanCheck_Show()
  If wellcheck = True Then
   Rows([Ô]19:27[Ô]).Select
   Selection.Rows.Hidden = True
if wellcheck = false Then [ô] ou if wellcheck = [Ô][Ô] Then
   Rows([Ô]18:28[Ô]).Select
   Selection.Rows.Hidden = False
  End If
End Sub  



[Ô]E conhecereis a verdade, e a verdade vos libertará. João 8:32[Ô]


#356286 - 29/10/2010 15:48:36

MARCELGARCIA
MACAE
Cadast. em:Outubro/2010


Citação:
:
tenta inverter assim

  Sub WellPlanCheck_Show()
  If wellcheck = True Then
   Rows([Ô]18:28[Ô]).Select
   Selection.Rows.Hidden = False
  Else
   Rows([Ô]19:27[Ô]).Select
   Selection.Rows.Hidden = True
  End If
End Sub  


ou

Sub WellPlanCheck_Show()
  If wellcheck = True Then
   Rows([Ô]19:27[Ô]).Select
   Selection.Rows.Hidden = True
if wellcheck = false Then [ô] ou if wellcheck = [Ô][Ô] Then
   Rows([Ô]18:28[Ô]).Select
   Selection.Rows.Hidden = False
  End If
End Sub  



Já havia tentado e não havia funcionado!

Valeu pela moral ae!

Abs

_________________________________________
Marcel Garcia

#356288 - 29/10/2010 16:04:36

LUIZCOMINO
SAO PAULO
Cadast. em:Maio/2009


Você está colocando o código no evento certo?, não seria no evento click?


[Ô]E conhecereis a verdade, e a verdade vos libertará. João 8:32[Ô]


#356289 - 29/10/2010 16:06:57

MARCELGARCIA
MACAE
Cadast. em:Outubro/2010


Última edição em 29/10/2010 16:11:58 por MARCELGARCIA

Mudei para click e nada....

O que eu creio que esteja acontecendo é que não o IF não consegue interpretar o valor [Ô]True[Ô] do Checkbox... ele interpreta como se estivesse sempre em false... independente da seleção...

_________________________________________
Marcel Garcia

#356290 - 29/10/2010 16:14:58

MARCELO-TREZE
SAO VICENTE
Cadast. em:Abril/2009


tenta assim


Sub WellPlanCheck_Show()
  If wellcheck = 1Then
   Rows([Ô]19:27[Ô]).Select
   Selection.Rows.Hidden = True
  Else
If wellcheck = 0 Then
   Rows([Ô]18:28[Ô]).Select
   Selection.Rows.Hidden = False
End If
  End If
End Sub
  

________________________________________________________________________________________
O orgulho cega até os sábios, ao ponto de não percebam que não são tão sábios como pensam.



#356292 - 29/10/2010 16:24:15

MARCELGARCIA
MACAE
Cadast. em:Outubro/2010


o problema esta no primeiro IF....

Tentei isso tbm mas... a msma coisa...

Ele não consegue validar o checkbox se for true
soh compreende o checkbox como false

Abs

_________________________________________
Marcel Garcia

#356293 - 29/10/2010 16:35:51

LUIZCOMINO
SAO PAULO
Cadast. em:Maio/2009


por padrão ele assume a propriedade value mas tenta ai:

Sub WellPlanCheck_Show()
  If wellcheck.value = True Then [ô] ou  If wellcheck.value = 1
   Rows([Ô]19:27[Ô]).Select
   Selection.Rows.Hidden = True
  Else
   Rows([Ô]18:28[Ô]).Select
   Selection.Rows.Hidden = False
  End If
End Sub  

[Ô]E conhecereis a verdade, e a verdade vos libertará. João 8:32[Ô]


#356294 - 29/10/2010 16:38:54

MARCELGARCIA
MACAE
Cadast. em:Outubro/2010


quando eu insiro o .value eu recebo:

  Runtime Error [ô]424[ô] Object Require

_________________________________________
Marcel Garcia

 Tópico anterior Próximo tópico Novo tópico


Para responder este tópico o login é requerido
Se você já possui uma conta de usuário por favor faça seu login
Se você não possui uma conta de usuário use a opção Criar usuário