Reputation: 15
I´m having problems with my code I want this code to copy cells from one sheet to another but with the following trick (english is not my first language, Sorry )
In "sheet1" there is "date and ticket number" always in the same cell, but I also want to copy a list of values that can change in amount...(A10) all these values go to "sheet2" in the same row... "date1" "ticket123" "itemA" "amount" "date1" "ticket123" "itemB" "amount2"
Private Sub CommandButton1_Click()
filalibre = Sheets("sheet2").Range("a1048576").End(xlUp).Row + 1
ActiveSheet.Range("a10").Select
fila = 10
While ActiveCell.Value <> ""
Sheets("sheet2").Cells(filalibre, 1) = ActiveSheet.Range("E4")
Sheets("sheet2").Cells(filalibre, 2) = ActiveSheet.Range("E2")
Sheets("sheet2").Cells(filalibre, 3) = ActiveSheet.Offset(0, 0)
Sheets("sheet2").Cells(filalibre, 4) = ActiveSheet.Offset(0, 1)
filalibre = filalibre + 1
ActiveCell.Offset(1, 0).Select
Wend
Call limpieza
End Sub
What can I read to fix this... or can anyone help me
Upvotes: 1
Views: 68
Reputation: 266
Since you have not mentioned the exact problem or the error you see, I can see some possible sources of an issue.
Replace
Sheets("sheet2").Cells(filalibre, 3) = ActiveSheet.Offset(0, 0)
Sheets("sheet2").Cells(filalibre, 4) = ActiveSheet.Offset(0, 1)
By
Sheets("sheet2").Cells(filalibre, 3) = ActiveCell.Offset(0, 0)
Sheets("sheet2").Cells(filalibre, 4) = ActiveCell.Offset(0, 1)
Besides this,there are a few other improvements that can be done to your code. But first try to get it working without an error.
Upvotes: 1