i_gencheva
New Member
- Joined
- Jul 30, 2017
- Messages
- 6
I need some assistance from you. Have 2 sheets, named Sheet1 and Sheet2. In sheet2 in column C from C5 to end i could enter some text or date. Then i need from the same sheet, Sheet2 to find corresponding data from the cells A and B in the filled row with cells from columns E and and B in Sheet 1. Then to paste the entered text or date from Sheet2 to column F in sheet1 on the corresponding found row. Here is the code i have so far but it works only for row 5 from Sheet2:
Code:
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