遍历值并使用VBA进行过滤-我需要知道如何

时间:2019-03-19 13:31:42

标签: excel vba

下面只是为在Rawdata或RemoveDup工作表中找到的第一个值创建电子邮件:(

我已经尝试了如下所述的方法,但是仍然无法正常工作。

请帮助

Sub Macro1()

     Sheets("RawData").Select
        Columns("A:A").Select
        Selection.Copy
        Sheets.Add(After:=Sheets(Sheets.Count)).Name = "DupRemoved"
        ActiveSheet.Paste
        Application.CutCopyMode = False
        ActiveSheet.Range("$A$1:$A$1000").RemoveDuplicates Columns:=1, Header:=xlYes

    Dim Cll As Range
    For Each Cll In Selection
    If Cll.Value < 0 Then
    Cll.Value = Sheets("Sheet1").Range("Opp").Value




        Worksheets("FilteredData").Range("$A$2:$S$1224").Cells.ClearContents
        Sheets("RawData").Select
        ActiveSheet.Range("$A$1:$S$1224").AutoFilter Field:=1, Criteria1:= _
            Sheets("Sheet1").Range("Opp").Value
        Rows("1:1").Select
        Range(Selection, Selection.End(xlDown)).Select
        Selection.Copy
        Rows("1:1").Select
        Sheets("FilteredData").Select
        Range("A1").Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
            Sheets("Mail").Select
           ActiveSheet.Range("$A$1:$S$1224").AutoFilter Field:=1, Criteria1:= _
            Sheets("Sheet1").Range("Opp").Value
    Sheets("RawData").Select
        Rows("1:1").Select
        ActiveSheet.ShowAllData
        Sheets("Home").Select

        End If

        Next Cll

        Call Macro2



      End Sub

0 个答案:

没有答案