Robert Hall
Robert Hall

Reputation: 191

Select range of columns in excel table

I need to be able to select a range of columns in a table. I have the Start and End number of the columns

Dim GetStartColumn As Integer
Dim GetEndColumn As Integer

GetStartColumn = RoomPricesTbl.ListColumns("Room Number").Range.Column - 
RoomPricesTbl.HeaderRowRange.Column + 1
GetEndColumn = RoomPricesTbl.ListColumns("Band 4").Range.Column - RoomPricesTbl.HeaderRowRange.Column 
+ 1

Any help would be great. Also, if it can be done by names, that would be good also.

Thanks

Upvotes: 1

Views: 888

Answers (1)

HTH
HTH

Reputation: 2031

although you hardly need to select anything, that's the code

With ActiveSheet.ListObjects("RoomPricesTbl")
    .Parent.Range(.ListColumns("Room Number").Range, .ListColumns("Band 4").Range).Select
End With

Upvotes: 2

Related Questions