Este fórum está sendo desativado

Depois de 9 anos, este fórum será desativado. Mas calma.... estamos migrando para uma comunidade no DISCORD. Junte-se a nós.

ENTRAR PARA DISCORD

Tópicos relacionados a códigos VBA, gravação de macros, etc.
Por douglasgoulart40
Posts
#55902
Boa tarde!
Gostaria de saber ou quem puder me ajudar, fazer uma validação que, ao aparecer a caixa do Inputbox e ao clicar no campo vazio, fornecer uma mensagem de campo obrigatório e logo após aparecer novamente para digitar. Vou colocar o código aqui:

Sub cadastro_agenda()

nome = InputBox("Digite o nome:")
telefone = InputBox("Digite o telefone:")
setor = InputBox("Digite o setor:")

lin = Range("A1").End(xlDown).Row + 1

Cells(lin, 1) = nome
Cells(lin, 2) = telefone
Cells(lin, 3) = setor

Espero que possam me dar essa luz! Forte abraço!

End Sub
Por babdallas
#56245
Código: Selecionar todos
Option Explicit

Sub cadastro_agenda()
    Dim vrtNome         As Variant
    Dim vrtTelefone     As Variant
    Dim vrtSetor        As Variant
    Dim lngLin          As Long
    
    With wshTeste
        Do
            vrtNome = InputBox("Digite o nome:")
        Loop While vrtNome = vbNullString
        
        Do
            vrtTelefone = InputBox("Digite o telefone:")
        Loop While vrtTelefone = vbNullString
        
        Do
            vrtSetor = InputBox("Digite o setor:")
        Loop While vrtSetor = vbNullString
        
        lngLin = .Range("A1").End(xlUp).Row + 1
        
        .Cells(lngLin, 1) = vrtNome
        .Cells(lngLin, 2) = vrtTelefone
        .Cells(lngLin, 3) = vrtSetor
    End With
End Sub
Você não está autorizado a ver ou baixar esse anexo.
long long title how many chars? lets see 123 ok more? yes 60

We have created lots of YouTube videos just so you can achieve [...]

Another post test yes yes yes or no, maybe ni? :-/

The best flat phpBB theme around. Period. Fine craftmanship and [...]

Do you need a super MOD? Well here it is. chew on this

All you need is right here. Content tag, SEO, listing, Pizza and spaghetti [...]

Lasagna on me this time ok? I got plenty of cash

this should be fantastic. but what about links,images, bbcodes etc etc? [...]

Estamos migrando para uma comunidade no Discord