![]() |
Active Cell
I'm confused, the help file states that ActiveCell would return the range
object. However, when I call ActiveCell , I"m getting the value of the cell not the range?? MsgBox = "You are currently in Cell " & ActiveCell How can I return the Cell that is currently selected? Ron |
Active Cell
A range object contains a lot of information including the value, the
address, and formating. If you want the address then use the following MsgBox = "You are currently in Cell " & ActiveCell.address "Ronio" wrote: I'm confused, the help file states that ActiveCell would return the range object. However, when I call ActiveCell , I"m getting the value of the cell not the range?? MsgBox = "You are currently in Cell " & ActiveCell How can I return the Cell that is currently selected? Ron |
Active Cell
Lose the = and add .address
MsgBox "You are currently in Cell " & ActiveCell.Address -- Don Guillett Microsoft MVP Excel SalesAid Software "Ronio" wrote in message ... I'm confused, the help file states that ActiveCell would return the range object. However, when I call ActiveCell , I"m getting the value of the cell not the range?? MsgBox = "You are currently in Cell " & ActiveCell How can I return the Cell that is currently selected? Ron |
Active Cell
Ronio
The ActiveCell property only returns the upper left cell of the selected range (which is indeed a range object). But, if you want to return the whole range, then use the RangeSelection property instead. "Ronio" wrote: I'm confused, the help file states that ActiveCell would return the range object. However, when I call ActiveCell , I"m getting the value of the cell not the range?? MsgBox = "You are currently in Cell " & ActiveCell How can I return the Cell that is currently selected? Ron |
Active Cell
Not always...
If you select A1:E9 and hit the tab a few times, you'll see the activecell changing, but the selection doesn't change. And you could use plain old Selection instead of RangeSelection. joeeng wrote: Ronio The ActiveCell property only returns the upper left cell of the selected range (which is indeed a range object). But, if you want to return the whole range, then use the RangeSelection property instead. "Ronio" wrote: I'm confused, the help file states that ActiveCell would return the range object. However, when I call ActiveCell , I"m getting the value of the cell not the range?? MsgBox = "You are currently in Cell " & ActiveCell How can I return the Cell that is currently selected? Ron -- Dave Peterson |
Active Cell
Thank you for pointing that out. But I believe that immediately following a
range selection, activecell is the upper left cell of the selection range. Following your first thread, then there is a diiference between Selection and SelectionRange. If an image or chart is selected after the range selection, then Selection will return the image or chart and not the range, while RangeSelection will return the last selected range. Is this not correct? "Dave Peterson" wrote: Not always... If you select A1:E9 and hit the tab a few times, you'll see the activecell changing, but the selection doesn't change. And you could use plain old Selection instead of RangeSelection. joeeng wrote: Ronio The ActiveCell property only returns the upper left cell of the selected range (which is indeed a range object). But, if you want to return the whole range, then use the RangeSelection property instead. "Ronio" wrote: I'm confused, the help file states that ActiveCell would return the range object. However, when I call ActiveCell , I"m getting the value of the cell not the range?? MsgBox = "You are currently in Cell " & ActiveCell How can I return the Cell that is currently selected? Ron -- Dave Peterson |
Active Cell
But who knows what was selected and when--or what was activated?
And I think if I were writing a macro that depended on the current selection, I think I'd use selection, but make sure it was a range. If TypeName(Selection) < "Range" Then MsgBox "please select a range" Exit Sub End If But yep, activewindow.selectionrange will return a range object. joeeng wrote: Thank you for pointing that out. But I believe that immediately following a range selection, activecell is the upper left cell of the selection range. Following your first thread, then there is a diiference between Selection and SelectionRange. If an image or chart is selected after the range selection, then Selection will return the image or chart and not the range, while RangeSelection will return the last selected range. Is this not correct? "Dave Peterson" wrote: Not always... If you select A1:E9 and hit the tab a few times, you'll see the activecell changing, but the selection doesn't change. And you could use plain old Selection instead of RangeSelection. joeeng wrote: Ronio The ActiveCell property only returns the upper left cell of the selected range (which is indeed a range object). But, if you want to return the whole range, then use the RangeSelection property instead. "Ronio" wrote: I'm confused, the help file states that ActiveCell would return the range object. However, when I call ActiveCell , I"m getting the value of the cell not the range?? MsgBox = "You are currently in Cell " & ActiveCell How can I return the Cell that is currently selected? Ron -- Dave Peterson -- Dave Peterson |
All times are GMT +1. The time now is 06:54 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com