Copy until the last filled line
Solved
touroul
Posted messages
520
Registration date
Status
Member
Last intervention
-
touroul Posted messages 520 Registration date Status Member Last intervention -
touroul Posted messages 520 Registration date Status Member Last intervention -
Hello forum
I'm looking to copy the contents of cells A6:Ax to the clipboard using a macro
Ax is the last row containing text at the bottom of my table.
Could I ask for your help?
Thanks in advance for this!
Configuration: Windows / Excel 2010 / Firefox 42.0
I'm looking to copy the contents of cells A6:Ax to the clipboard using a macro
Ax is the last row containing text at the bottom of my table.
Could I ask for your help?
Sub Macro1()
Range("A3:Ax").Select
Selection.Copy
End Sub
Thanks in advance for this!
Configuration: Windows / Excel 2010 / Firefox 42.0
2 answers
-
Hello hello,
First, we need to define what the last row of your table is. We will store this value in a variable. Then, we will copy the rows based on this variable.
So let's go for it:
Sub Macro1() 'Start of the macro Dim DL As Long 'Definition of the variable DL = Cells(Application.Rows.Count, 1).End(xlUp).Row 'I define the last row where column A is not empty Range("A3:A" & DL).Copy 'I copy the rows from A3 to the last row (no need to select here, unless you really want to, in that case, add the select line instead of Copy then Selection.Copy End Sub 'End of the macro
Best regards.