12

I would like to get a range of the first column from a larger range. For example:

If the range is $E$9:$I$259, the result should be $E$9:$E259

How can I achieve this?

0

1 Answer 1

23

By using the columns collection of the range object like so:

Range("$E$9:$I$259").Columns(1)
Sign up to request clarification or add additional context in comments.

4 Comments

But how to get multiple columns Range("$E$9:$E259").Columns(1:3) ?
You can't do neat and tidy things like 1:3 in VBA and I don't think you would have 3 columns in the range E9:E259. Either be more selective in your range selection and use all columns or loop through the columns collection.
with non contiguous range it fails. Had to sort an array created from range's adress, and then join it together first : Dim TempA() , A as Range : TempA = Split(A, ",") : QuickSort (TempA) : Set A = A.Parent.Range(Join(TempA, ",")).Address : Set Col= A.columns(1) .
Didn't you mean Range("$E$9:$I$259").Columns(1) ?

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.