我在VBA中遇到类型不匹配错误,我不知道为什么.
此宏的目的是浏览Excel电子表格中的列并将所有电子邮件添加到数组中.每个电子邮件添加到第一个数组后,它也应该添加到第二个数组,但在@符号处分成两部分,以便将名称与域分开.像这样:person@gmail.com以person和gmail.com.
我得到的问题是,当它到达应该拆分电子邮件的点时,它会抛出类型不匹配错误.
特别是这部分:
strDomain = Split(strText, "@")
这是完整的代码:
Sub addContactListEmails()
Dim strEmailList() As String 'Array of emails
Dim blDimensioned As Boolean 'Is the array dimensioned?
Dim strText As String 'To temporarily hold names
Dim lngPosition As Long 'Counting
Dim strDomainList() As String
Dim strDomain As String
Dim dlDimensioned As Boolean
Dim strEmailDomain As String
Dim i As Integer
Dim countRows As Long
'countRows = Columns("E:E").SpecialCells(xlVisible).Rows.Count
countRows = Range("E:E").CurrentRegion.Rows.Count
MsgBox "The number …Run Code Online (Sandbox Code Playgroud) 这是一个功课问题,我得到了基础知识,但我似乎无法找到正确的搜索两个并行数组的方法.
原始问题:设计一个具有两个并行数组的程序:一个String名为people初始化名为7人的String数组,以及一个名为phoneNumbers初始化的朋友电话号码数组.该程序应允许用户输入一个人的姓名(或一个人姓名的一部分).然后它应该在people数组中搜索该人.如果找到该人,则应从phoneNumbers阵列中获取该人的电话号码并显示该号码.如果找不到该人,程序应显示一条消息,表明如此.
我目前的代码:
# create main
def main():
# take in name or part of persons name
person = raw_input("Who are you looking for? \n> ")
# convert string to all lowercase for easier searching
person = person.lower()
# run people search with the "person" as the parameters
peopleSearch(person)
# create module to search the people list
def peopleSearch(person):
# create list with the names of the …Run Code Online (Sandbox Code Playgroud)