Ir ao conteúdo
  • Cadastre-se

Excel - executar macro automaticamente


entoaar

Posts recomendados

Tenho uma planilha que ao clicar em determinada celula e acionar a macro ele executa com dados daquela linha, gostaria que alguém me ajudasse a fazer com que de acordo com o resultado da célula executaria a macro, exemplo quando na coluna tivesse a palavra concluído.

Se a macro abaixo:

Sub SendEMail()

Dim Email As String, Subj As String

Dim Msg As String, URL As String

Email = Cells(ActiveCell.Row, 10)

Subj = Cells(ActiveCell.Row, 4)

Msg = ""

Msg = Msg & "Senhor " & Cells(ActiveCell.Row, 1) & "," & vbCrLf & vbCrLf & "Here is some precanned text before the BODY info in the spreadsheet. " & vbCrLf & vbCrLf & Cells(ActiveCell.Row, 13) & vbCrLf & vbCrLf & " And here is some more precanned text in the macro AFTER the Body stuff."

'Replace spaces with %20 (hex)

Subj = Application.WorksheetFunction.Substitute(Subj, " ", "%20")

Msg = Application.WorksheetFunction.Substitute(Msg, " ", "%20")

'Replace carriage returns with %0D%0A (hex)

Msg = Application.WorksheetFunction.Substitute(Msg, vbCrLf, "%0D%0A")

'Create the URL

URL = "mailto:" & Email & "?subject=" & Subj & "&body=" & Msg

'Execute the URL (start the email client)

ShellExecute 0&, vbNullString, URL, vbNullString, vbNullString, vbNormalFocus

'Wait two seconds before sending keystrokes

Application.Wait (Now + TimeValue("0:00:02"))

Application.SendKeys "%r"

End Sub

Link para o comentário
Compartilhar em outros sites

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Sobre o Clube do Hardware

No ar desde 1996, o Clube do Hardware é uma das maiores, mais antigas e mais respeitadas comunidades sobre tecnologia do Brasil. Leia mais

Direitos autorais

Não permitimos a cópia ou reprodução do conteúdo do nosso site, fórum, newsletters e redes sociais, mesmo citando-se a fonte. Leia mais

×
×
  • Criar novo...

 

GRÁTIS: ebook Redes Wi-Fi – 2ª Edição

EBOOK GRÁTIS!

CLIQUE AQUI E BAIXE AGORA MESMO!