Hi everyone
I have number 1 to 10 in Column A and <code>name</code> in Column B. What I am trying to accomplish is to check the <code>name</code> in cell B2, if empty then it will copy the number from cell A2 to cell H2. But if cell B2 already contains a name then it will copy the number from cell A3 to cell H2 and so on.
here is my code
I have number 1 to 10 in Column A and <code>name</code> in Column B. What I am trying to accomplish is to check the <code>name</code> in cell B2, if empty then it will copy the number from cell A2 to cell H2. But if cell B2 already contains a name then it will copy the number from cell A3 to cell H2 and so on.
here is my code
Code:
<code>Private Sub CommandButton1_Click()
If IsEmpty(Range("B2")) Then
Range("A2").Copy destination:=Range("H2")
Else
Worksheets("sheet6").Cells(Rows.Count, 1).End(xlUp).Offset(0, 1).Copy _
destination:=Range("H2")
End If
End Sub</code>