Select a range of cells starting from the Active Cell
<p>I need help with the code below. What I am trying to do is, starting from the active cell (which could be any cell), select all cells to the right (=first column) + all the cells to the left (=last column) + all the cells above until the highlighted row + all the cell below until the highlighted row. Please see the attached data <a href="http://i.stack.imgur.com/N4S08.png" rel="nofollow">Sample Data</a></p>

<p>As an example, in the sample data, if the active cell is G6, then the code would select the entire range from A2 to J7. Similarly, if the active cell is F12, the code would select the entire range from A11 to J13. </p>

<pre><code>Sub sel()
Dim LastCol As Long
With ActiveSheet
    LastCol = .Range("A1").SpecialCells(xlCellTypeLastCell).Column
Dim FirstCol As Long
With ActiveSheet
LastVrow = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row
Range(Cells(WorksheetFunction.Max(1, Selection.Row, LastVrow), _
  WorksheetFunction.Max(1, Selection.Column, LastCol)), _
  Cells(WorksheetFunction.Min(Selection.Worksheet.Rows.Count, _
  Selection.Row), _
  WorksheetFunction.Min(Selection.Worksheet.Columns.Count, _
  Selection.Column, FirstCol))).Select
 End With
End With
 End With
End Sub
</code></pre>