ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Choosing Active Cell (https://www.excelbanter.com/excel-programming/411453-choosing-active-cell.html)

WLMPilot

Choosing Active Cell
 
I have a worksheet that contains 12 budgets (one for each month). Each
budget is identical in size (rows & columns). I have two commandbuttons that
allow me to sort two different ways. The user simply enters the month
(numeric value 1-12) and that particular budget is sorted.

What I am looking for is an automatic way to determine which budget is being
looked at, ie if I am viewing May's budget, logic would be I would be sorting
May's budget. I figure if I can determine what cell is currently selected,
then I can determine the range to be sorted automatically without the user
having to enter the month.

What code would determine what cell is selected?

Thanks,
Les

Gary''s Student

Choosing Active Cell
 
Sub whereami()
MsgBox (ActiveCell.Address)
MsgBox (ActiveSheet.Name)
End Sub

--
Gary''s Student - gsnu200788

Norman Jones[_2_]

Choosing Active Cell
 
Hi Les,

Dim Rng As Range

Set Rng = ActiveCelll

MsgBox Rng.Address(External:=True)


---
Regards.
Norman

"WLMPilot" wrote in message
...
I have a worksheet that contains 12 budgets (one for each month). Each
budget is identical in size (rows & columns). I have two commandbuttons
that
allow me to sort two different ways. The user simply enters the month
(numeric value 1-12) and that particular budget is sorted.

What I am looking for is an automatic way to determine which budget is
being
looked at, ie if I am viewing May's budget, logic would be I would be
sorting
May's budget. I figure if I can determine what cell is currently
selected,
then I can determine the range to be sorted automatically without the user
having to enter the month.

What code would determine what cell is selected?

Thanks,
Les



Norman Jones[_2_]

Choosing Active Cell
 
Hi Les,

Slightly over enthusiastic typing:


Set Rng = ActiveCelll


should be:

Set Rng = ActiveCell



---
Regards.
Norman


All times are GMT +1. The time now is 01:19 AM.

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