I’m new to VBA and I’m trying this for loop out, but I think my “To” counter is wrong. I want it to perform the specified actions until there are no more columns left to cut.
What is happening is, I have a horizontal set of data(Column “T” to “EV”) that I am cutting and pasting in order vertically on column S. It works, but I get this error still:
I get:
Run-time error ‘1004’:
This selection is not valid.
There are several possible reasons:
- Copy and paste areas cannot overlap unless they’re the same size and shape.
- If you are using the Create from Selection command, the row or column containing the proposed names won’t be included in the(cuts off here)
Code:
Dim x As Integer
For x = 0 To ActiveCell.CurrentRegion.Columns.Count
ActiveCell.Select
ActiveCell.Offset(0, x).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Cut
Range("S3000").Select
ActiveCell.End(xlUp).Select
ActiveCell.Offset(1, 0).Select
ActiveSheet.Paste
Range("T11").Select
Next x
Not tested, written directly here, but it should work…
There’s no point changing the active cell. It just slows down your code.