0

我正在努力寻找这个问题的答案......

每个月我都会收到一个电子表格,里面装满了客户数据,这些数据是从某种 CRM 软件中提取的原始数据,这些数据是一团糟。有些单元格被合并,有些则没有。当您取消合并整个工作表时,您最终得到的数据意味着一列随机分布在 3 列中并与另一数据混合,即电子邮件地址分布在 3 列中并与邮政编码混合。

我想做的是在 S、T 和 U 列中搜索包含“@”的单元格,并将整个电子邮件地址移动(而不是复制)到同一行的 V 列。

我怎样才能做到这一点?

4

2 回答 2

0

您可以在 V1 中使用以下公式来实现这一点:

=INDEX(S1:U1,MATCH(TRUE,NOT(ISERROR(SEARCH("@",S1:U1))),0))

公式需要以数组公式的形式输入,即按Ctrl- Shift- Enter

于 2013-02-14T09:49:06.560 回答
0

按 Alt+F11 打开 Visual Basic 编辑器,然后单击插入、模块。将其粘贴进去。或者,只需在此处下载示例文件。然后在视图/宏下,这个 movemail() 例程将在那里。运行。

我接受支票、汇票、贝宝、比特币... :-) j/j 享受。

Sub moveemail()

Dim ws As Worksheet
Dim thisCell As Range, nextCell As Range, lookAt As Range
Dim foundAt As String, lookFor As String
Dim lastRow As Long
lookFor = "@"
On Error GoTo Err

'get last populated cell
Set ws = Application.ActiveSheet
With ws
    If WorksheetFunction.CountA(Cells) > 0 Then
        lastRow = Cells.Find(what:="*", SearchOrder:=xlByRows, _
        SearchDirection:=xlPrevious).Row
    End If
End With

' go cell by cell looking for @ from row 1 to row 10000
Set lookAt = ActiveSheet.Range("S1:U" & lastRow)
Set thisCell = lookAt.Find(what:=lookFor, LookIn:=xlValues, lookAt:=xlPart, SearchDirection:=xlNext)
    If Not thisCell Is Nothing Then
        Set nextCell = thisCell
        Do
            Set thisCell = lookAt.FindNext(After:=thisCell)
            If Not thisCell Is Nothing Then
                foundAt = thisCell.Address

                            thisCell.Copy Range("V" & thisCell.Row)
                            thisCell.ClearContents
            Else
                Exit Do
            End If
            If thisCell.Address = nextCell.Address Then Exit Do
        Loop
    Else
        'MsgBox SearchString & " not Found"
        Exit Sub
    End If
Err:
    'MsgBox Err.Number
    Exit Sub
End Sub
于 2015-06-12T21:18:58.123 回答