2017-08-14 49 views
-1

我想創建一個Excel文件,人們可以進入他們的電子郵件地址,只要5人加入他們的E-Mail中消息被髮送到所有這些電子郵件。目前我已成立由B2一個憤怒 -的Excel/VBA疊代細胞在一列從電池獲取電子郵件,確認併發送自動通知

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) 
'My Code is here 
End Sub 

我嘗試遍歷一列,但沒有發現這是一個很好的解決方案:

爲了節省當我做下面執行VBA-萬客隆到B99 我需要從電池獲得的電子郵件,忽略空/空細胞,我需要以某種方式查看電子郵件,如果其有效

Dim eMailList As String 
Dim eMailCount As Integer 

eMailCount = 0 
eMailList = "" 

Dim eMail As String 

Dim rng As Range: Set rng = ThisWorkbook.Worksheets("Tabelle1").Range("B2:B99") 
Dim i As Integer 
For i = 1 To rng.Rows.Count 
    eMail = rng.Cells(RowIndex:=i, ColumnIndex:="B").Text 
eMailList = eMailList & eMail & "; " 
Next 


Set objOutlook = CreateObject("Outlook.Application") 
    Set objMail = objOutlook.CreateItem(0) 
    With objMail 
     .To = eMailList 
     .Subject = "DummyText" 
     .Body = "DummyText" 
     .send 
    End With 

我的問題是(正則表達式):

  1. 我怎樣才能容易在一個特定列的單元格重複?

  2. 我怎樣才能從細胞的電子郵件 - 。文本​​。價值?

  3. 如何使用正則表達式在VBA/Excel中驗證電子郵件?

  4. 如何列出的電子郵件和消息發送到每個電子郵件

林提前高興的任何幫助/提示/建議 感謝

+3

請一次只問一個問題。如果你這樣做對你的所有sepreate問題搜索,你應該找到很多答案。 – Luuklag

回答

0

下面的代碼將讓你開始了,代碼裏面的解釋說明:

Dim Rng As Range, C As Range 

Set Rng = ThisWorkbook.Worksheets("Tabelle1").Range("B2:B99") 
' loop through all cells in Range (Column "B") 
For Each C In Rng 
    If Trim(C.Value2) <> "" Then ' <-- check that cell isn't empty 
     ' --- Add Here another IF criteria to validate your E-Mail --- 

     eMail = Rng.Value2 ' <-- read the value2 of the cell (without the cell's format) 
     eMailList = eMailList & eMail & "; " 
    End If 
Next C