0

I would like to delete all the rows from Cell "A1" to the "ActiveCell.Address"

Tried this code:

Range(" A1:ActiveCell.Address").Delete Shift:=xlUp

But I'm getting an error on this (runtime error 1004).

Isn't it possible to refer to the ActiveCell's address within a range?

If so, is there an alternative?

Is my code incorrect?

Thanks in Advance.

2 Answers 2

1

In your code you aren't evaluating the ActiveCell.Address as you've put it inside the string. Try with:

Range("A1:" & ActiveCell.Address).Delete Shift:=xlUp

Also this will only delete the cells between A1 and the ActiveCell. To delete the rows use:

Range("A1:" & ActiveCell.Address).EntireRow.Delete Shift:=xlUp
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks a lot, your first line {Range("A1:" & ActiveCell.Address).Delete Shift:=xlUp} solved my problem perfectly! Your secend row wasn't neccesery for me because (at this stage of the code, at this particular sheet) I only have values/text is the A Column. (I should have mentioned that in my question). Thanks for reminding though!
0

You don't even need the address for this:

Range("A1", ActiveCell).Delete Shift:=xlUp

will suffice.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.