Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Excel VBA for selecting an entire column starting from a specific cell

Tags:

excel

vba

How do I select the entire column after a specific cell?

For example, I would like to select the entire column after C24 so that includes C24, C25, ...

I have worked with the following snippet with no success:

ActiveSheet.Range("C24", ActiveSheet.Range("C24").End(xlDown)).Select

Could someone please correct my error?

like image 650
czchlong Avatar asked Oct 31 '12 19:10

czchlong


People also ask

How do I select an entire column from a selected cell?

Select the letter at the top to select the entire column. Or click on any cell in the column and then press Ctrl + Space. Select the row number to select the entire row. Or click on any cell in the row and then press Shift + Space.

How do you include an entire column starting at a particular row in a formula in Excel?

Actually there is a Fill command on Excel Ribbon to help you apply formula to an entire column or row quickly. Firstly enter the formula =(A1*3+8)/5 into the Cell C1 (the first cell of column where you will enter the same formula), secondly select the entire Column C, and then click Home > Fill > Down.

How do you reference a whole column in Excel?

How to reference an entire column or row in Excel. When you are working with an Excel worksheet that has a variable number of rows, you may want to refer to all of the cells within a specific column. To reference the whole column, just type a column letter twice and a colon in between, for example A:A.

How do I reference the entire column except the first row in Excel?

If your list does not contain any blank cells, you can use the shortcut to select entire column but the first row. Select the header or the first row of your list and press Shift + Ctrl + ↓(the drop down button), then the list has been selected except the first row.


2 Answers

You just need to wrap the two references within a Range:

Range(ActiveSheet.Range("C24"), ActiveSheet.Range("C24").End(xlDown)).Select
like image 109
A. Webb Avatar answered Nov 15 '22 21:11

A. Webb


Here's an approach that will work even if there are cells with content below C24:

With ActiveSheet
.Range(.Range("C24"), .Range("C" & .Rows.Count)).Select
End With
like image 41
Doug Glancy Avatar answered Nov 15 '22 19:11

Doug Glancy