1

I am trying to make a selection of an entire column except the first row. I used the following code which i got from https://www.extendoffice.com/documents/excel/1628-excel-select-column-except-header-first-row.html

Sub SelectColumn()
Dim xColIndex As Integer
Dim xRowIndex As Integer
xColIndex = Application.ActiveCell.Column
xRowIndex = Application.ActiveSheet.Cells(Rows.Count, xColIndex).End(xlUp).Row
Range(Cells(2, xColIndex), Cells(xRowIndex, xColIndex)).Select
End Sub

but the RowIndex variable reads to the value 1. So the section happens from Row2 to Row1 instead of Row2 to the Last row. How can i get this corrected

1
  • Refer this Commented Jan 19, 2018 at 15:40

1 Answer 1

1

If you really need to select the whole column (why?) then this. In your example you can't have any data in the relevant column.

Range(Cells(2, xColIndex), Cells(rows.count, xColIndex)).Select
Sign up to request clarification or add additional context in comments.

1 Comment

My pleasure.You might want to get into the habit of accepting answers so as to engender good will.

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.