gpt4 book ai didi

excel - 将用户名(数组)与电子邮件(数组)匹配

转载 作者:行者123 更新时间:2023-12-04 22:28:10 27 4
gpt4 key购买 nike

使用 Excel 2013。经过多年的寻找和适应,我的第一篇文章。

我正在尝试将当前 App 用户(即“John Smith”)与他的电子邮件地址“jsmith@work.com”进行匹配。

使用两个字符串:1 个用于用户(1 到 3),另一个用于 eaddress(1 到 3)。
我想获取当前用户的电子邮件地址,以便在单独的 Sub 中使用,以便在电子邮件中抄送当前用户。

我试过 For Each i In user , 并将 eName 设置为 eaddress(i) .
这仅返回最后列出的用户/电子邮件。

Private Sub (useremail)
Dim user (1 To 3), eaddress (1 To 3), fullName, eName As String

fullName = Application.UserName
user(1) = "John Smith"
user(2) = "Debbie Adams"
user(3) = "Karen Jones"

eaddress(1) = "jsmith@work.com"
eaddress(2) = "dadams@work.com"
eaddress(3) = "kjones@work.com"

For i = 1 To 3
'For Each i In user
fullName = user(i)
eName = eaddress(i)
'Exit For
debug.print "User is " & fullname & "email to " & eName
Next i



寻找当前用户的 eaddress/eName(用于单独的 Sub to email 文件)。

最佳答案

您可以使用 Dictionary 让这更容易

Private Sub UsereMail()
Dim dictInfo, fullName

fullName = Application.UserName

Set dictInfo = CreateObject("Scripting.Dictionary")
dictInfo.Add "John Smith", "jsmith@work.com"
dictInfo.Add "Debbie Adams", "dadams@work.com"
dictInfo.Add "Karen Jones", "kjones@work.com"

If dictInfo.Exists(fullName) Then
Debug.Print "User is " & fullName & " email to " & dictInfo(fullName)
End If
End Sub

关于excel - 将用户名(数组)与电子邮件(数组)匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55817189/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com