Olá,
Sou novato em VBA, uso o Excel 2010, numa macro que estou desenvolvendo, tenho a Sub Encaixe() que faz o encaixe numa planilha agenda.
Para inserir esse encaixe tenho que testar a reserva atual e validar se essa reserva contem uma série de palavras chave que não permitiriam o encaixe, para isso escrevi o código a seguir:
If ActiveCell = ("Descanso" Or "Dia" Or "Médico" Or "Visita" Or "Pessoal" Then GoTo Inicio Else
If ActiveCell = ("Projeto") Then
ActiveCell.Select
Selection.Cut
ActiveCell.Range("CCelula").Select
ActiveSheet.Paste
ActiveCell.Range("CCelula").Select
Selection.Copy
ActiveCell.Range("CCelula").Select
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
Else GoTo Inicio
End If
End If
Não consigo achar ou entender o que está errado, agradeço a ajuda,
Mrc
Vídeo recomendado
https://youtu.be/diWPPPhW-9E
https://youtu.be/diWPPPhW-9E
Erro de compilação: End If sem bloco If - Resolvido
Erro de compilação: End If sem bloco If - Resolvido
Editado pela última vez por MrcFz em Qua Mai 11, 2022 7:33 pm, em um total de 1 vez.
Re: Erro de compilação: End If sem bloco If
Não faço ideia de como isso esteja funcionando, mas acho que está faltando um "fecha parênteses" antes do primeiro Then. Aqui o código corrigido (sem testes obviamente):
Código: Selecionar todos
If ActiveCell = ("Descanso" Or "Dia" Or "Médico" Or "Visita" Or "Pessoal") Then
GoTo Inicio
Else
If ActiveCell = ("Projeto") Then
ActiveCell.Select
Selection.Cut
ActiveCell.Range("CCelula").Select
ActiveSheet.Paste
ActiveCell.Range("CCelula").Select
Selection.Copy
ActiveCell.Range("CCelula").Select
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
Else
GoTo Inicio
End If
End If