Excel 在VBA dosn'中从一张纸传递到另一张纸;使用UserForm CommandButton时不起作用

Excel 在VBA dosn'中从一张纸传递到另一张纸;使用UserForm CommandButton时不起作用,excel,vba,Excel,Vba,我这里有这个代码,但由于某种原因它不起作用 Public Sub CommandButton3_Click() 'agregar' ComboBox2.Value = sel For i = 2 To 200 celda = ActiveCell.Row Add = Worksheets("Programación").Cells(i, 2) If sel = Add Then Sheets("Programación").Activate Sheets("Programac

我这里有这个代码,但由于某种原因它不起作用

Public Sub CommandButton3_Click()
'agregar'

ComboBox2.Value = sel
For i = 2 To 200
celda = ActiveCell.Row
Add = Worksheets("Programación").Cells(i, 2)
If sel = Add Then

    Sheets("Programación").Activate
    Sheets("Programación").Select
    Tipo = Sheets("Programación").Cells(i, 3).Text
    Expl = Sheets("Programación").Cells(i, 4).Text
    Recom = Sheets("Programación").Cells(i, 5).Text
    Vul = Sheets("Programación").Cells(i, 6).Text
    Ame = Sheets("Programación").Cells(i, 7).Text
    Rie = Sheets("Programación").Cells(i, 8).Text
    HA = Sheets("Programación").Cells(i, 2).Text

    Sheets("Matriz_de_Hallazgos").Activate
    Sheets("Matriz_de_Hallazgos").Select
    Sheets("Matriz_de_Hallazgos").Cells(celda, 2) = Tipo
    Sheets("Matriz_de_Hallazgos").Cells(celda, 4) = HA
    Sheets("Matriz_de_Hallazgos").Cells(celda, 5) = Expl
    Sheets("Matriz_de_Hallazgos").Cells(celda, 6) = Vul
    Sheets("Matriz_de_Hallazgos").Cells(celda, 7) = Ame
    Sheets("Matriz_de_Hallazgos").Cells(celda, 8) = Rie
    Sheets("Matriz_de_Hallazgos").Cells(celda, 9) = Recom

  celda = celda + 1
Sheets("Matriz_de_Hallazgos").Cells(celda, 4).Select

i = 201
End If

Next i


ComboBox2.Clear

End Sub
我要做的是,宏在“Programación”工作表中搜索相同的组合框文本,如果文本相同,则保存一些文本类别并将它们粘贴到“Matriz de Hallazgos”工作表上,就像搜索、查找(如果相等)、复制和粘贴一样。
如果你们能给我一些建议,我会很有帮助的,因为你们想比较组合框和单元格中的值,我认为行

ComboBox2.Value = sel
应该是

sel = ComboBox2.Value

检索值以便正确比较。现在,当前的第一行是将combobox设置为sel中存储的任何内容,如果变量还没有被使用,这将是无效的。当与单元格值进行比较时,Sel将保持为空。

i=201
-您应该使用
Exit For
来代替此选项这里的
Sel
是什么?是的。