Monday, October 07, 2019

Excel VBA Hack : Go to the First Column of Your Table (Not Sheet)

You can't use (which you can get from the Macro Recorder) :

Selection.End(xlToLeft).Select  -- because, if you're already at the first column, you exit the Table and, if you're too far to the right (and still in the Table), you don't go to the first column. Why don't they ask you what you're really trying to do :) ?

What does work :

(only within a Sub, mind you :)

Cells(ActiveCell.Row, ActiveCell.ListObject.Range.Column).Select

Excel VBA recipes - better than making a separate post for each one..

How to get the name of the first worksheet in your workbook :

ActiveWorkbook.Worksheets(1).Name

No comments: