Basically, I 'd like to combine values from two cell and then display it in another new cell after I click a button. The tricky part is every time when I enter a new value, it should display in the next row. For example, I shall combine value from A1 and B1 and pass it to C1. the next time I re-enter A1 and B1, the new value should pass to C2. Here is the code I wrote:
Private Sub CommandButton2_Click()
Dim count As Integer
Dim rowNo As String
Dim val As String
Dim val2 As String
Dim sum As String
count = 1
rowNo = "C" + CStr(count)
If (Range("A1") <> "" And Range("B1") <> "") Then
val = Range("A1")
val2 = Range("B1")
sum = val + "/" + val2
Worksheets("Sheet1").Range(rowNo).Value = sum
count = count + 1
End If
End Sub
I am new to excel VBA, the above code only write value in A1 and it didnt go to next row when I re-enter the values, can anyone help me to solve this?