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.
#41337
Na rotina abaixo, eu precisava que antes de IMPRIMIR fosse obrigatorio estar preenchido as celulas C41 e A30. No formato que esta ele esta imprimindo mesmo sem as celulas C41 e A30 estarem preenchidas.



Sub Imprimir()

'primeira parte

If ActiveSheet.Name = "Plan13" Then

'verifica se o Range C41 está preenchido
If Range("C41").Value = "" Then
MsgBox ("Campo Corretor esta Vazio !!"), vbCritical, "Preenchimento Obrigatorio !!!"
Cancel = True
End If

'verifica se o Range A30 está preenchido
If Range("A30").Value = "" Then
MsgBox ("Campo Frete esta Vazio !!"), vbCritical, "Preenchimento Obrigatorio !!!"
Cancel = True
End If

End If

'segunda parte

Dim W As Worksheet

Set W = Sheets("Plan13") 'Troque para o nome da sua planilha

W.Range("J4").Font.ColorIndex = 2
W.Range("A30").Font.ColorIndex = 2
W.Range("J4").Font.ColorIndex = 1
W.Range("A30").Font.ColorIndex = 1

'terceira parte ( imprimir celulas selecionadas)

ActiveSheet.PageSetup.PrintArea = "$A$1:$L$61"
ActiveWindow.SelectedSheets.PrintOut Copies:=5



End Sub
#41349
Substitua as duas ocorrências de Cancel = True por Exit Sub
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