Sunday 2 December 2018

microsoft excel - How to make a macro that will transfer data to another sheet starting at a specific cell and (on subsequent invocations) work its way downwards?

I have a DATA INPUT cell (cell B3) in SHEET1. I want to make a macro code that when the macro button is pressed, data from cell B3 of SHEET1 will be copied to cell C5 of SHEET2 and also deleting of the data inputted in cell B3 of SHEET1. And then when I input another data and pressed the button again, the data will be copied to the next row of SHEET2, in this case cell C6. Then, cell C7, C8, and so on.


I tried to make a code for this, but I can't make it start on cell C5. It always starts from cell C2 then downwards. I tried researching codes like "Startrow", but I can't make it work.


Please see code below:


Sub Button1_Click()
Response = MsgBox("Are you sure?", vbYesNo)
If Response = vbNo Then Exit Sub
Dim nextrow As Long
nextrow = Worksheets("Sheet2").Cells(Rows.Count, "C").End(xlUp).Row + 1
Worksheets("Sheet1").Range("B3").Copy Worksheets("Sheet2").Range("C" & nextrow)
Worksheets("Sheet1").Range("B3").ClearContents
End Sub

No comments:

Post a Comment

Where does Skype save my contact's avatars in Linux?

I'm using Skype on Linux. Where can I find images cached by skype of my contact's avatars? Answer I wanted to get those Skype avat...