I have cell sheet1 B2 with customer ID. When I click confirm button I want the cell value B2 to be added to A2 in sheet2.
Then it should put the next number to B2 checking with A2 in sheet2.
I have cell sheet1 B2 with customer ID. When I click confirm button I want the cell value B2 to be added to A2 in sheet2.
Then it should put the next number to B2 checking with A2 in sheet2.
Waqar
Just use this line to copy the value across:
Sheet2.Range("A2").Value = Sheet1.Range("B2").Value
before you use the code (you've worked out) to add the next ID to Sheet1 B2.
Revision 1: If you want to put the value of B2 in Sheet 2 A3 the next time, A4 after that, then this can be used instead:
With Sheet2
r= .Range("A" & Rows.Count).End(xlUp).Row 'find last non-empty cell in column A
.Range("A" & r+1).Value = Sheet1.Range("B2").Value
End With
(assuming you allow the new ID to be the last item in column A).
Hope this solves your problem. Have a good weekend.