ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Selecting data programmatically (https://www.excelbanter.com/excel-programming/410815-selecting-data-programmatically.html)

guest

Selecting data programmatically
 
Is there anyway we can programmatically select the data rows and columns that
the active cell belongs to? Similar what excel charting does.
For example in case of Excel chart you just select a single cell, and say
insert chart it automatically detects the data that the active cell is part
of and charts it.

Gary''s Student

Selecting data programmatically
 
Sub rowss()
ActiveCell.EntireRow.Select
End Sub

Sub columnss()
ActiveCell.EntireColumn.Select
End Sub


--
Gary''s Student - gsnu200785


"guest" wrote:

Is there anyway we can programmatically select the data rows and columns that
the active cell belongs to? Similar what excel charting does.
For example in case of Excel chart you just select a single cell, and say
insert chart it automatically detects the data that the active cell is part
of and charts it.


guest

Selecting data programmatically
 
I think this logic selects only one row and one column or am I missing
something here?



"Gary''s Student" wrote:

Sub rowss()
ActiveCell.EntireRow.Select
End Sub

Sub columnss()
ActiveCell.EntireColumn.Select
End Sub


--
Gary''s Student - gsnu200785


"guest" wrote:

Is there anyway we can programmatically select the data rows and columns that
the active cell belongs to? Similar what excel charting does.
For example in case of Excel chart you just select a single cell, and say
insert chart it automatically detects the data that the active cell is part
of and charts it.


Norman Jones[_2_]

Selecting data programmatically
 
Hi Guest,

Try:

Dim Rng As Range

Set Rng = Activecell.CurrentReguon



---
Regards.
Norman


"guest" wrote in message
...
Is there anyway we can programmatically select the data rows and columns
that
the active cell belongs to? Similar what excel charting does.
For example in case of Excel chart you just select a single cell, and say
insert chart it automatically detects the data that the active cell is
part
of and charts it.



Norman Jones[_2_]

Selecting data programmatically
 
Hi Guest,

Set Rng = Activecell.CurrentReguon



Correcting a typo, try:

'=========
Public Sub Tester()
Dim Rng As Range

Set Rng = ActiveCell.CurrentRegion
MsgBox Rng.Address(0, 0)

End Sub
'<<=========


---
Regards.
Norman

Gary''s Student

Selecting data programmatically
 
Yes.

If you want the "table" that the cell is a part of, follow Norman's
suggestion:

Sub missive()
ActiveCell.CurrentRegion.Select
End Sub

--
Gary''s Student - gsnu200785


"guest" wrote:

I think this logic selects only one row and one column or am I missing
something here?



"Gary''s Student" wrote:

Sub rowss()
ActiveCell.EntireRow.Select
End Sub

Sub columnss()
ActiveCell.EntireColumn.Select
End Sub


--
Gary''s Student - gsnu200785


"guest" wrote:

Is there anyway we can programmatically select the data rows and columns that
the active cell belongs to? Similar what excel charting does.
For example in case of Excel chart you just select a single cell, and say
insert chart it automatically detects the data that the active cell is part
of and charts it.


guest

Selecting data programmatically
 
thanks.

"Norman Jones" wrote:

Hi Guest,

Set Rng = Activecell.CurrentReguon



Correcting a typo, try:

'=========
Public Sub Tester()
Dim Rng As Range

Set Rng = ActiveCell.CurrentRegion
MsgBox Rng.Address(0, 0)

End Sub
'<<=========


---
Regards.
Norman



All times are GMT +1. The time now is 12:52 AM.

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