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:
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...
dim c as range
for each c in range("t1").currentregion
range("s3000").end(xlup).offset(1,0)= c.value
c.clear
next c
There's no point changing the active cell. It just slows down your code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With