In this article, we are going to learn how to update the data from one sheet to another sheet through VBA in Microsoft Excel.
Let’s take an example to understand how and where we can use this Macro in our data to reduce our daily work.
We want to write this code for those employees who are working in a call center. When clients call them they ask for basic details like User_Name, User_ID, Phone_Number, and Problem_ID, they need such a code to work systematically.
Now we want to apply the macro for such a context when a call comes and they note down all the above mentioned details into an excel sheet, and when they click on update, that data should be updated in another sheet.
To update the data from one sheet to another sheet, follow below given steps:-
Private Sub CommandButton1_Click()
Dim User_Name As String, User_ID As Integer, Phone_Number As Double, Problem_ID As Integer
Worksheets("Sheet1").Select
User_Name = Range("B2")
User_ID = Range("B3")
Phone_Number = Range("B4")
Problem_ID = Range("B5")
Worksheets("Sheet2").Select
Worksheets("Sheet2").Range("A1").Select
If Worksheets("Sheet2").Range("A1").Offset(1, 0) <> "" Then
Worksheets("Sheet2").Range("A1").End(xlDown).Select
End If
ActiveCell.Offset(1, 0).Select
ActiveCell.Value = User_Name
ActiveCell.Offset(0, 1).Select
ActiveCell.Value = User_ID
ActiveCell.Offset(0, 1).Select
ActiveCell.Value = Phone_Number
ActiveCell.Offset(0, 1).Select
ActiveCell.Value = Problem_ID
Worksheets("Sheet1").Select
Worksheets("Sheet1").Range("B2").Select
End Sub
Code Explanation:-First, we had defined all the variables. Then we had defined the range for every variable, and then described the range for all the variables. And, we had also defined that where and in which range data will be updated after clicking on Update button.
This is the way we can update the data from one sheet to another sheet through VBA in Microsoft excel.
Download - How to Update data One sheet to Another Sheet - xlsm
The applications/code on this site are distributed as is and without warranties or liability. In no event shall the owner of the copyrights, or the authors of the applications/code be liable for any loss of profit, any problems or any damage resulting from the use or evaluation of the applications/code.
hi i tried above but not working in VBA, i would like to use but not familier in VBA or not done programming
pl. support i want to use it for data recording