Moving Down a Cell in VBA (Beginner)
blackpearl35
-
Bidouilleu_R Posted messages 1209 Status Membre -
Bidouilleu_R Posted messages 1209 Status Membre -
Hello everyone,
So, I want to use macros so that whenever I wish, I have a series of cells that will go and paste below another table.
But I have a problem because I can go to the bottom of the table with (xldown) but I can't tell it to go to the next row; yes, it's logical because if it pastes my info at the end of the table it will delete the data that is already at the end.. so it should go one line down.
Here is my current (simple) macro:
Range("I121:L121").Select
Selection.Copy
Sheets("Données").Select
Range("B1").Select
Selection.End(xlDown).Select
I think that's where I need to add something...
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False (yes it's a special paste but it doesn't change anything)
If any experts can help me that would be great :D
Thanks in advance!
Julien
Configuration: Windows Vista / Internet Explorer 8.0
So, I want to use macros so that whenever I wish, I have a series of cells that will go and paste below another table.
But I have a problem because I can go to the bottom of the table with (xldown) but I can't tell it to go to the next row; yes, it's logical because if it pastes my info at the end of the table it will delete the data that is already at the end.. so it should go one line down.
Here is my current (simple) macro:
Range("I121:L121").Select
Selection.Copy
Sheets("Données").Select
Range("B1").Select
Selection.End(xlDown).Select
I think that's where I need to add something...
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False (yes it's a special paste but it doesn't change anything)
If any experts can help me that would be great :D
Thanks in advance!
Julien
Configuration: Windows Vista / Internet Explorer 8.0
I found another solution so I didn't test yours.
I created a variable at the beginning, something I had forgotten to do and then it worked by itself :) :
Dim NOligne As Byte
Sheets("Données").Select
NOligne = Range("B1").End(xlDown).Row + 1
and then I just copied the cells.
thanks!
NOligne returns the number of lines, so be careful
it's better to declare it as an integer or a Long
I prefer
Dim NOligne As Long