VBA - Select rows that a cell contain a specific text and send to email

ibianchini123

New Member
Joined
Jul 6, 2016
Messages
2
Hi everyone,
What I am trying to do is basically create a macro that select all rows that have the same text in the cell and send the email.

Select the header and the paths that are the same and send via email to a specific destinatary, in other words:


PathAccount TypeAccountDisplay NamePermission (Simple)
I:\Alt_InvestmentsGroupCSFB\_FaosaoAlt_InvestmentsC_FaosaoAlt_InvestmentsCModify
I:\Alt_InvestmentsGroupCSFB\_FaosaoAlt_InvestmentsR_FaosaoAlt_InvestmentsRRead and Execute
I:\Alt_InvestmentsGroupCSFB\_FaosaoAltInvestments_BloombergR_FaosaoAltInvestments_BloombergRList Folder Contents
I:\Alt_InvestmentsGroupCSFB\_FaosaoAltInvestments_SecretariasC_FaosaoAltInvestments_SecretariasCList Folder Contents
I:\Alt_InvestmentsGroupCSFB\_FaosaoAltInvestments_SecretariasR_FaosaoAltInvestments_SecretariasRList Folder Contents
I:\Alt_InvestmentsGroupCSFB\_FAOsaoDatF_FAOsaoDatFFull Control
I:\Alt_Investments_InitiativesGroupCSFB\_FaosaoAltInvestments_InitiativesC_FaosaoAltInvestments_InitiativesCModify
I:\Alt_Investments_InitiativesGroupCSFB\_FaoSaoAltInvestments_InitiativesL_FaoSaoAltInvestments_InitiativesLList Folder Contents
I:\Alt_Investments_InitiativesGroupCSFB\_FaosaoAltInvestments_InitiativesR_FaosaoAltInvestments_InitiativesRRead and Execute
I:\Alt_Investments_InitiativesGroupCSFB\_FAOsaoDatF_FAOsaoDatFFull Control
I:\AnaliseGroupCSFB\_EQTsaoAnaliseWorkingC_EQTsaoAnaliseWorkingCList Folder Contents
I:\AnaliseGroupCSFB\_EQTsaoAnaliseWorkingR_EQTsaoAnaliseWorkingRList Folder Cont

<tbody>
</tbody>

Send to: junior@email.com
PathAccount TypeAccountDisplay NamePermission (Simple)
I:\Alt_InvestmentsGroupCSFB\_FaosaoAlt_InvestmentsC_FaosaoAlt_InvestmentsCModify
I:\Alt_InvestmentsGroupCSFB\_FaosaoAlt_InvestmentsR_FaosaoAlt_InvestmentsRRead and Execute
I:\Alt_InvestmentsGroupCSFB\_FaosaoAltInvestments_BloombergR_FaosaoAltInvestments_BloombergRList Folder Contents
I:\Alt_InvestmentsGroupCSFB\_FaosaoAltInvestments_SecretariasC_FaosaoAltInvestments_SecretariasCList Folder Contents
I:\Alt_InvestmentsGroupCSFB\_FaosaoAltInvestments_SecretariasR_FaosaoAltInvestments_SecretariasRList Folder Contents

<tbody>
</tbody>


Send to: marcos@email.com

PathAccount TypeAccountDisplay NamePermission (Simple)
I:\Alt_Investments_InitiativesGroupCSFB\_FaosaoAltInvestments_InitiativesC_FaosaoAltInvestments_InitiativesCModify
I:\Alt_Investments_InitiativesGroupCSFB\_FaoSaoAltInvestments_InitiativesL_FaoSaoAltInvestments_InitiativesLList Folder Contents
I:\Alt_Investments_InitiativesGroupCSFB\_FaosaoAltInvestments_InitiativesR_FaosaoAltInvestments_InitiativesRRead and Execute
I:\Alt_Investments_InitiativesGroupCSFB\_FAOsaoDatF_FAOsaoDatFFull Control

<tbody>
</tbody>

This is the VBA code that I trying to make (incomplete):


Sub Send_Range()

' Select the range of cells on the active worksheet.
'ActiveSheet.Range("A:A").Select



'============================================
Range("A2").Select
i = Mid(ActiveCell.Value, 4, Len(ActiveCell.Value))


While Len(ActiveCell.Value) < 4
'Encontrar celula com conteudo de diretorio valido
ActiveCell.Offset(1, 0).Select
Wend
'Pegar o conteudo da celula e armazenar em variavel

ConteudoLinnha = Range(Selection, Selection.End(xlToRight))
Selection.Copy

conteudo = Selection.Copy
MsgBox conteudo
'=============================================




' Show the envelope on the ActiveWorkbook.
ActiveWorkbook.EnvelopeVisible = True

' Set the optional introduction field thats adds
' some header text to the email body. It also sets
' the To and Subject lines. Finally the message
' is sent.
With ActiveSheet.MailEnvelope
.Introduction = "body."
.Item.To = "email"
.Item.Subject = "Test"
.Item.Send
End With
End Sub
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.

Forum statistics

Threads
1,214,520
Messages
6,120,011
Members
448,935
Latest member
ijat

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top