ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Check Selection (https://www.excelbanter.com/excel-programming/286367-check-selection.html)

Chris Gorham[_3_]

Check Selection
 
Hi,

I want to make sure that when I write code such as
activecell.select that the macro doesn't bug out because
an object such as a chart happens to be currently selected
on the s/sheet and not a cell range.

thks...Chris

Tim Zych[_4_]

Check Selection
 
If Typename(ActiveCell) = "Range" Then
ActiveCell.Select
End If

"Chris Gorham" wrote in message
...
Hi,

I want to make sure that when I write code such as
activecell.select that the macro doesn't bug out because
an object such as a chart happens to be currently selected
on the s/sheet and not a cell range.

thks...Chris




Vasant Nanavati

Check Selection
 
Tim; did you mean:

If Typename(Selection) = "Range" Then

?

Regards,

Vasant.


"Tim Zych" wrote in message
...
If Typename(ActiveCell) = "Range" Then
ActiveCell.Select
End If

"Chris Gorham" wrote in message
...
Hi,

I want to make sure that when I write code such as
activecell.select that the macro doesn't bug out because
an object such as a chart happens to be currently selected
on the s/sheet and not a cell range.

thks...Chris






Tim Zych[_4_]

Check Selection
 
Well, no because Typename(ActiveCell) returned "Nothing" if the activated
object was a chart.
Looks like one and the same for the purpose as stated.


"Vasant Nanavati" <vasantn *AT* aol *DOT* com wrote in message
...
Tim; did you mean:

If Typename(Selection) = "Range" Then

?

Regards,

Vasant.


"Tim Zych" wrote in message
...
If Typename(ActiveCell) = "Range" Then
ActiveCell.Select
End If

"Chris Gorham" wrote in message
...
Hi,

I want to make sure that when I write code such as
activecell.select that the macro doesn't bug out because
an object such as a chart happens to be currently selected
on the s/sheet and not a cell range.

thks...Chris








Vasant Nanavati

Check Selection
 
You're right, Tim ... that's interesting. I thought it would throw an error.
I should have tested before I posted!

Regards,

Vasant.

"Tim Zych" wrote in message
...
Well, no because Typename(ActiveCell) returned "Nothing" if the activated
object was a chart.
Looks like one and the same for the purpose as stated.


"Vasant Nanavati" <vasantn *AT* aol *DOT* com wrote in message
...
Tim; did you mean:

If Typename(Selection) = "Range" Then

?

Regards,

Vasant.


"Tim Zych" wrote in message
...
If Typename(ActiveCell) = "Range" Then
ActiveCell.Select
End If

"Chris Gorham" wrote in message
...
Hi,

I want to make sure that when I write code such as
activecell.select that the macro doesn't bug out because
an object such as a chart happens to be currently selected
on the s/sheet and not a cell range.

thks...Chris










All times are GMT +1. The time now is 07:23 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com