我需要你的帮助 . 有2张,名为Sheet1和Sheet2 . 在从C5到C的C列的sheet2中,我可以输入一些文本或日期 . 然后我需要从同一张Sheet2中找到填充行中单元格A和B的相应数据,其中单元格中的列E和B中有单元格 . 然后将输入的文本或日期从Sheet2粘贴到sheet1中的列F在相应的找到的行上 . 这是我到目前为止的代码,但它只适用于Sheet2的第5行:

Private Sub CommandButton2_Click()
Dim sht As Worksheet, Rng As Range, r As Range
Dim bCellsFilled As Boolean
Set sht = ActiveSheet
Set Rng = sht.Range(sht.Range("C5"), sht.Cells(sht.Rows.Count, "C").End(xlUp))
bCellsFilled = True

For Each r In Rng
    If r.Value = "" Then
        bCellsFilled = False
    End If
Next r

If bCellsFilled = True Then
    If Worksheets("Sheet2").Range("A5").Value = Worksheets("Sheet1").Range("E5").Value Then
  If Worksheets("Sheet2").Range("B5").Value = Worksheets("Sheet1").Range("B5").Value Then
  Worksheets("Sheet2").Range("C5").Copy Worksheets("Sheet1").Range("F5") 'Copy Then
           Worksheets("Sheet1").Range("E5").ClearContents
  Worksheets("Sheet2").Range("C5").ClearContents
 End If
 End If
End If

非常感谢您的评论