Posts

Showing posts from November, 2018

Excel select columns numerically in VBA

https://www.excelcampus.com/library/vba-reference-column-numbers/comment-page-1/#comment-84622 I used a variant of this to select columns for sorting:    lastcol = ws.Cells(1, ws.Columns.Count).End(xlToLeft).Column    ws.Columns(1).Resize(, lastcol).Select Thank you Mr.    Jon Acampora  !: Sub Column_Number_References() 'This macro contains VBA examples of how to 'reference or select a column by numbers instead of letters      Dim lCol As Long           'The standard way to reference columns by letters     Range("A:B").Select     Range("A:A").Select     Columns("A").Select     Columns("A:F").Select            'Select a single column with Columns property      'The following line selects column B (column 2) Columns(2).Select            'Select columns based on a variable     lCol = 2     Columns(lCol).Select            'Select columns based on variable of a cell's value      'Cell A1 must c