vba_emailcheck02

Sub Emcheck()

'if part code bushi 99991 and email addres bu han "@fax or @FAX or @cma or @CMA"

Dim dic
Set dic = CreateObject("scripting.dictionary")

For x = 11 To Range("a65536").End(xlUp).ROW


dic(Cells(x, "a").Value) = 0

Next x

For x = 11 To Range("a65536").End(xlUp).ROW


If (Cells(x, "c") <> "9999999901" And Cells(x, "c") <> "9999999902" And InStr(Cells(x, "e"), "@cma") + InStr(Cells(x, "e"), "@CMA") + InStr(Cells(x, "E"), "fax.") + InStr(Cells(x, "E"), "FAX.") = 0 And _
Cells(x, "e") <> "") Or InStr(Cells(x, "D"), "CMA CGM") + InStr(Cells(x, "D"), "ANL CHINA LIMITED") + InStr(Cells(x, "D"), "CMA SHIPS") + InStr(Cells(x, "D"), "CMA-CGM") >= 1 Then

dic(Cells(x, "a").Value) = dic(Cells(x, "a").Value) + 1

End If

Next x

Range("Q11").Resize(dic.Count) = Application.Transpose(dic.Keys)
Range("R11").Resize(dic.Count) = Application.Transpose(dic.Items)

dic.RemoveAll



For Y = 11 To Range("Q65536").End(xlUp).ROW

  On Error Resume Next

If Cells(Y, "R") = 0 Then

Cells(k + 11, "k") = Cells(Y, "Q")
Cells(k + 11, "L") = Range("A:A").Find(Cells(Y, "Q")).Offset(0, 7)
Cells(k + 11, "M") = Range("A:A").Find(Cells(Y, "Q")).Offset(0, 8)
Cells(k + 11, "N") = Range("A:A").Find(Cells(Y, "Q")).Offset(0, 9)

k = k + 1

End If

Next Y

'cha zhao dpcode


    Set conn = CreateObject("adodb.connection")
    Set rst = CreateObject("ADODB.recordset")
 
    conn.Open "provider=Microsoft.ACE.OLEDB.12.0;extended properties=excel 12.0;data source=" & "C:\Users\GSC.BFU\Desktop\bOB\SHA Email Ask Atuo\DP Code.xlsx"
    
  
  rst.Open "select *  from [Sheet1$]", conn, adOpenKeyset, adLockOptimistic
  




For X1 = 11 To Range("K65536").End(xlUp).ROW

If Len(Cells(X1, "l")) > 6 Then

Cells(X1, "O") = rst.Fields(Cells(X1, "m") & Right(Cells(X1, "L"), 2))

Else

Cells(X1, "O") = rst.Fields(Cells(X1, "m") & "MA")

End If

Next X1


    rst.Close
    conn.Close
    Set rst = Nothing
    Set conn = Nothing

  On Error GoTo 0
  
Columns("Q:R").Delete

[k10] = "NO EMAIL BL"
[l10] = "Import Voyage"
[m10] = "Port"
[n10] = "ETA"
[O10] = "DP Code"

Range("K10:O10").Interior.ColorIndex = 36



Columns("N").NumberFormat = "m/d/yyyy"
Columns("K:O").EntireColumn.AutoFit

MsgBox "done"


End Sub



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值