Question : range xldown &xright

How Do I Select A Section Spaning Both Rows And Colunms
Use Macro's
Bad Code:
Sub Macro10()
    Range(ActiveCell, ActiveCell.End(xlDown)).Select
    Range(ActiveCell, ActiveCell.End(xlToRight)).Select
End Sub

Answer : range xldown &xright

Hi,

There are two ways to do this....

The first is....

Sub test()
    Dim Col As Range
    Set Col = Range("A1").End(xlToRight)
    Range("A1", Col.End(xlDown)).Select
End Sub

The other is....

Sub test2()
    Range("B2", Range("B2").SpecialCells(xlCellTypeLastCell)).Select
End Sub

This selects the last cell that has ever been used in the sheet rather than the last currently filled cell.

Hope this helps

Frazer
Random Solutions  
 
programming4us programming4us