'Copy first and last column
I want to make a macro that copy's the first and last column to another sheet. I have made a recorded macro that selects column A and L in one sheet called Saldobalanse RHB input and copies them to the sheet: Saldobalanse RHB. The problem with this is that the numbers I need do not ALWAYS appear in the column L, sometimes it is in K or J. That's why I would like to copy the first and the last column - wherever the placement is. Could someone help me edit my recorded macro to fit this? Please and thank you so much in advance.
Sub Makro6()
Makro6 Makro
Range("A:A,L:L").Select
Range("L1").Activate
Selection.Copy
Sheets("Saldobalanse RHB").Select
Range("A1").Select
ActiveSheet.Paste
End Sub
Solution 1:[1]
One of these examples should work for you:
Range.CurrentRegion
Dim Target As Range
Set Target = Range("A1").CurrentRegion
Target.Columns(1).Copy Sheets("Saldobalanse RHB").Range("A1")
Target.Columns(Target.Columns.Count).Copy Sheets("Saldobalanse RHB").Range("B1")
ActiveSheet.UsedRange
Dim Target As Range
Set Target = ActiveSheet.UsedRange
Target.Columns(1).Copy Sheets("Saldobalanse RHB").Range("A1")
Target.Columns(Target.Columns.Count).Copy Sheets("Saldobalanse RHB").Range("B1")
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | TinMan |
