简体   繁体   中英

How to Excel Copy from one Sheet to another with vba

I need some help for my Excel sheet, I have the first sheet and this is blank and on the seconde sheet i have a list and in the column D i can change the value starts from 1. And when i changed in the column a cell then it should copy the row to the first sheet.

thanks Regards

It is not clear for me what you want to do. If you want VBA to copy the row automatically, you should go to the module of the corresponding Worksheet in the VBA editor (in the list of the Wroksheets on the left, just double-click the Worksheet to open up the module associated with it). After that, write an event handler:

Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Column = 4 Then
        ActiveSheet.Rows(Target.Row).Copy Worksheets("Sheet1").Rows(whichRowYouNeed)
    End If
End Sub 

you should also write a routine to determine the 'whichRowYouNeed' It may be the end of the filled range on Worksheet1

Hey sorry for my bad statement, i try it again :)

The first sheet is blank,

The Second sheet is that:

When i add a number in column D then I want to copy this row, in that case row 8, copy to the first sheet starting from row 5.

I hope now it is better to understand

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM