我需要编辑一个Excel电子表格,以便一行自动从一个工作表(" Open_Followups")移动到另一个工作表(" Closed_Followups")如果它包含"是& #34;在专栏#34; I" ("活动已完成/已结束")。
我没有VBA经验,想知道这里有人能帮我创建代码吗?
工作表上第一列的屏幕截图。
不确定它是否重要,但我在Mac电脑上使用Excel 2016
答案 0 :(得分:0)
我为您编写了一个小脚本(在MS Excel中),在行B中搜索“y”,如果找到匹配,则将值从行A复制到工作表“Tabelle2”。 这只是一个例子(我不是来为你做你的工作;)) 使用它并将其导入工作簿并在需要时进行调整。
Private Sub CommandButton1_Click()
Dim LastRow As Long
Dim LastRow2 As Long
Dim counter As Integer
'get the last row in this sheet (column A)
With ActiveSheet
LastRow = .Cells(.Rows.Count, 1).End(xlUp).Row
End With
'get the last row in the sheet "Tabelle2" (column A)
With Sheets("Tabelle2")
LastRow2 = .Cells(.Rows.Count, 1).End(xlUp).Row
End With
'the counter is needed to add dynamically to "Tabelle2"
counter = LastRow2 + 1
'run from 1 to the last row in your first sheet
For i = 1 To LastRow
'search for matches
If Cells(i, 2).Text = "y" Then
'if found, write to "Tabelle2"
Sheets("Tabelle2").Cells(counter, 1).Value = Cells(i, 2).Offset(0, -1).Value
counter = counter + 1
End If
Next
End Sub