Enter a data an Excel cell I copy it to another Excel file

LoganTrk

New Member
Joined
Jan 24, 2019
Messages
17
Hello, I need that every time I enter a data an Excel cell I copy it to another Excel file, so that the one I had previously entered is not deleted, for example in the A2 cell in the aa.xlms file I entered the value "A" and then I click on the button of the macro, it is copied in the other file bb.xlms in cell A2. When you enter another value in A2 of the file aaa.xms the macro should copy it in cell A3 in the ahivo bb.xlms not replace what was previously entered. regards
Input “a” then “b” then “c “ ( aa.xlms)
Result (bb.xlms)
A
B
C


<tbody>
</tbody>
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Hello, I need that every time I enter a data an Excel cell I copy it to another Excel file, so that the one I had previously entered is not deleted, for example in the A2 cell in the aa.xlms file I entered the value "A" and then I click on the button of the macro, it is copied in the other file bb.xlms in cell A2. When you enter another value in A2 of the file aaa.xms the macro should copy it in cell A3 in the ahivo bb.xlms not replace what was previously entered. regards
Input “a” then “b” then “c “ ( aa.xlms)
Result (bb.xlms)
A
B
C

<tbody>
</tbody>
Paste the following code in the VBA module of the worksheet where you are entering the data:
The code presumes the values will be poked in the next available cell in "Sheet1" worksheet of "Book1" (for the code to run Book1 must be open at the time of data entry)
Rename Book1 and Sheet1 as per your need and you should be good to go

Code:
Private Sub Worksheet_Change(ByVal Target As Range)    Dim WB As Workbook
    Set WB = Workbooks("Book1")
    Addr = "$A$2"
    If Target.Address = Addr Then
        WB.Sheets("Sheet1").Range("A" & Rows.Count).End(xlUp).Offset(1, 0) = Target.Value
     End If
End Sub
 
Upvote 0
Paste the following code in the VBA module of the worksheet where you are entering the data:
The code presumes the values will be poked in the next available cell in "Sheet1" worksheet of "Book1" (for the code to run Book1 must be open at the time of data entry)
Rename Book1 and Sheet1 as per your need and you should be good to go

Code:
Private Sub Worksheet_Change(ByVal Target As Range)    Dim WB As Workbook
    Set WB = Workbooks("Book1")
    Addr = "$A$2"
    If Target.Address = Addr Then
        WB.Sheets("Sheet1").Range("A" & Rows.Count).End(xlUp).Offset(1, 0) = Target.Value
     End If
End Sub

Why should the file be open? Is there any way in which the file is closed?

 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,182
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top