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

Community
  • 1
  • 1
  • Refer [this](https://stackoverflow.com/questions/48134634/importing-multiple-text-files-using-vba-macro/48135025?noredirect=1#comment83255629_48135025) – Dy.Lee Jan 19 '18 at 15:40

1 Answers1

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
SJR
  • 22,986
  • 6
  • 18
  • 26
  • My pleasure.You might want to get into the habit of accepting answers so as to engender good will. – SJR Jan 19 '18 at 16:07