GeneralShamu
Board Regular
- Joined
- Jul 6, 2007
- Messages
- 127
Any ideas? I don't want to select A1 by default given there may subsections within these sheets.
Activecell.CurrentRegion.Range("A1").Select
ActiveCell.CurrentRegion.Cells(1, 1).Select
That Range("A1") sometimes throws code newbies for a loop, because at first glance it appears it might be selecting cell A1, when it is really selecting the first cell in the current region.
Sometimes, to avoid the confusion, I will write it like this:
It does the exact same thing as Richard's code, just represented a little differently.Code:ActiveCell.CurrentRegion.Cells(1, 1).Select
When going for the first cell (you can't depend of this method for other cells in the range unless you know it's a single column or row), I simply treat the range as a one-dimensional array...Sometimes, to avoid the confusion, I will write it like this:
It does the exact same thing as Richard's code, just represented a little differently.Code:ActiveCell.CurrentRegion.Cells(1, 1).Select
ActiveCell.CurrentRegion(1).Select
So there are embedded charts? If a chart is selected, what do you want to happen?
If TypeName(Selection)="Range" Then
ActiveCell.CurrentRegion.Range("A1").Select
Else
Activesheet.Range("A1").Select
End if