Hi All,
I am trying to create a VBA code to do the following task:
1. Look up a value on active sheet.
2. With that value, look in coloum "B" of sheet "Database".
3. Change the Value of a Cell to the Time in the same row but a different column on that sheet.
I have this so far, but it goes to the other sheet and then just inputs the Time into the original sheet instead of the updating the cells in the Database.
Private Sub CommandButton2_Click()
ref_number = Range("B9")
Sheets("Database").Activate
Last = Cells(Rows.Count, "B").End(xlUp).Row
For i = Last To 1 Step -1
If (Cells(i, "A").Value) = ref_number Then
Cells(i, "G") = Time
End If
Next i
End Sub
Can anyone offer any guidance regarding where I am going wrong? Would be much appreciated.
Thankyou
I am trying to create a VBA code to do the following task:
1. Look up a value on active sheet.
2. With that value, look in coloum "B" of sheet "Database".
3. Change the Value of a Cell to the Time in the same row but a different column on that sheet.
I have this so far, but it goes to the other sheet and then just inputs the Time into the original sheet instead of the updating the cells in the Database.
Private Sub CommandButton2_Click()
ref_number = Range("B9")
Sheets("Database").Activate
Last = Cells(Rows.Count, "B").End(xlUp).Row
For i = Last To 1 Step -1
If (Cells(i, "A").Value) = ref_number Then
Cells(i, "G") = Time
End If
Next i
End Sub
Can anyone offer any guidance regarding where I am going wrong? Would be much appreciated.
Thankyou