Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 7
Default Function for cursor location

Is there such an excel function that detects the cursor location?

Ie: If cursor is in A1, the contents of B1 should be "Cursor is in A1"

Thanks
--
sandyboy
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 747
Default Function for cursor location

There is no such function but there is now. You must paste it to a standard
module. However, it will only update when the worksheet is calculated:

Function CPos() As String
Application.Volatile
CPos = "Cursor is in " & ActiveCell.Address(False, False)
End Function

If you need it to update when the cell selection is changed (cursor position
changes) then you need to also paste this to the worksheet's module:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Me.Calculate
End Sub

To get it to work, enter this into the desired cell:
=CPos()

Regards,
Greg
  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3,101
Default Function for cursor location


Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Worksheets("Sheet1").Range("B2").Formula = CPosition()
Me.Calculate
End Sub



There is no such function but there is now. You must paste it to a standard
module. However, it will only update when the worksheet is calculated:

Function CPos() As String
Application.Volatile
CPos = "Cursor is in " & ActiveCell.Address(False, False)
End Function

If you need it to update when the cell selection is changed (cursor position
changes) then you need to also paste this to the worksheet's module:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Me.Calculate
End Sub

To get it to work, enter this into the desired cell:
=CPos()

Regards,
Greg

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 747
Default Function for cursor location

Mike,

We don't need to add the formula to the cell each time a cell selection is
made. By making the function volatile, it updates every time a sheet
calculation occurs, which the selection change code makes happen every time
cell selection changes. Not only is this not necessary, but hard coding it
into the event code defeats the purpose of the function - e.g. if you want to
change it to C1 then you also have to change the code. The way I have set it
up, just enter "=CPos()" in cell C1 and clear the formula in B1. Also, you
can enter the formula into multiple cells if you want.

I tested it. It works.

Regards,
Greg


"Mike" wrote:


Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Worksheets("Sheet1").Range("B2").Formula = CPosition()
Me.Calculate
End Sub



There is no such function but there is now. You must paste it to a standard
module. However, it will only update when the worksheet is calculated:

Function CPos() As String
Application.Volatile
CPos = "Cursor is in " & ActiveCell.Address(False, False)
End Function

If you need it to update when the cell selection is changed (cursor position
changes) then you need to also paste this to the worksheet's module:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Me.Calculate
End Sub

To get it to work, enter this into the desired cell:
=CPos()

Regards,
Greg

  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3,101
Default Function for cursor location

Greg your right but alot of times ok most of the time ok maybe sometimes
some people worry about =CPos() getting removed

"Greg Wilson" wrote:

Mike,

We don't need to add the formula to the cell each time a cell selection is
made. By making the function volatile, it updates every time a sheet
calculation occurs, which the selection change code makes happen every time
cell selection changes. Not only is this not necessary, but hard coding it
into the event code defeats the purpose of the function - e.g. if you want to
change it to C1 then you also have to change the code. The way I have set it
up, just enter "=CPos()" in cell C1 and clear the formula in B1. Also, you
can enter the formula into multiple cells if you want.

I tested it. It works.

Regards,
Greg


"Mike" wrote:


Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Worksheets("Sheet1").Range("B2").Formula = CPosition()
Me.Calculate
End Sub



There is no such function but there is now. You must paste it to a standard
module. However, it will only update when the worksheet is calculated:

Function CPos() As String
Application.Volatile
CPos = "Cursor is in " & ActiveCell.Address(False, False)
End Function

If you need it to update when the cell selection is changed (cursor position
changes) then you need to also paste this to the worksheet's module:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Me.Calculate
End Sub

To get it to work, enter this into the desired cell:
=CPos()

Regards,
Greg



  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 7
Default Function for cursor location

I appreciate all this, but problem is, i don't know how to make a module.. :c
I'd be happy if anyone can help me about this and can refer me to a site to
know more about this.

--
sandyboy


"Mike" wrote:

Greg your right but alot of times ok most of the time ok maybe sometimes
some people worry about =CPos() getting removed

"Greg Wilson" wrote:

Mike,

We don't need to add the formula to the cell each time a cell selection is
made. By making the function volatile, it updates every time a sheet
calculation occurs, which the selection change code makes happen every time
cell selection changes. Not only is this not necessary, but hard coding it
into the event code defeats the purpose of the function - e.g. if you want to
change it to C1 then you also have to change the code. The way I have set it
up, just enter "=CPos()" in cell C1 and clear the formula in B1. Also, you
can enter the formula into multiple cells if you want.

I tested it. It works.

Regards,
Greg


"Mike" wrote:


Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Worksheets("Sheet1").Range("B2").Formula = CPosition()
Me.Calculate
End Sub



There is no such function but there is now. You must paste it to a standard
module. However, it will only update when the worksheet is calculated:

Function CPos() As String
Application.Volatile
CPos = "Cursor is in " & ActiveCell.Address(False, False)
End Function

If you need it to update when the cell selection is changed (cursor position
changes) then you need to also paste this to the worksheet's module:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Me.Calculate
End Sub

To get it to work, enter this into the desired cell:
=CPos()

Regards,
Greg

  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3,101
Default Function for cursor location

Hi,

To create a standard module hit ALT + F11 to open VB editor and then right
click on the workbook project, insert - insert module and paste the code you
have been given in there.

Mike

"sandyboy" wrote:

I appreciate all this, but problem is, i don't know how to make a module.. :c
I'd be happy if anyone can help me about this and can refer me to a site to
know more about this.

--
sandyboy


"Mike" wrote:

Greg your right but alot of times ok most of the time ok maybe sometimes
some people worry about =CPos() getting removed

"Greg Wilson" wrote:

Mike,

We don't need to add the formula to the cell each time a cell selection is
made. By making the function volatile, it updates every time a sheet
calculation occurs, which the selection change code makes happen every time
cell selection changes. Not only is this not necessary, but hard coding it
into the event code defeats the purpose of the function - e.g. if you want to
change it to C1 then you also have to change the code. The way I have set it
up, just enter "=CPos()" in cell C1 and clear the formula in B1. Also, you
can enter the formula into multiple cells if you want.

I tested it. It works.

Regards,
Greg


"Mike" wrote:


Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Worksheets("Sheet1").Range("B2").Formula = CPosition()
Me.Calculate
End Sub



There is no such function but there is now. You must paste it to a standard
module. However, it will only update when the worksheet is calculated:

Function CPos() As String
Application.Volatile
CPos = "Cursor is in " & ActiveCell.Address(False, False)
End Function

If you need it to update when the cell selection is changed (cursor position
changes) then you need to also paste this to the worksheet's module:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Me.Calculate
End Sub

To get it to work, enter this into the desired cell:
=CPos()

Regards,
Greg

  #8   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,574
Default Function for cursor location

Sandyboy, if you want more information on what Greg Wilson is proposing, see
he http://www.ozgrid.com/VBA/Functions.htm#UDFIntro

Since Excel doesn't offer a built in function to do what you want to do, he
created a custom function, called a user defined function. That gets
inserted into a module.

The link above explains this in more detail.

Dave
--
A hint to posters: Specific, detailed questions are more likely to be
answered than questions that provide no detail about your problem.


"Mike" wrote:

Hi,

To create a standard module hit ALT + F11 to open VB editor and then right
click on the workbook project, insert - insert module and paste the code you
have been given in there.

Mike

"sandyboy" wrote:

I appreciate all this, but problem is, i don't know how to make a module.. :c
I'd be happy if anyone can help me about this and can refer me to a site to
know more about this.

--
sandyboy


"Mike" wrote:

Greg your right but alot of times ok most of the time ok maybe sometimes
some people worry about =CPos() getting removed

"Greg Wilson" wrote:

Mike,

We don't need to add the formula to the cell each time a cell selection is
made. By making the function volatile, it updates every time a sheet
calculation occurs, which the selection change code makes happen every time
cell selection changes. Not only is this not necessary, but hard coding it
into the event code defeats the purpose of the function - e.g. if you want to
change it to C1 then you also have to change the code. The way I have set it
up, just enter "=CPos()" in cell C1 and clear the formula in B1. Also, you
can enter the formula into multiple cells if you want.

I tested it. It works.

Regards,
Greg


"Mike" wrote:


Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Worksheets("Sheet1").Range("B2").Formula = CPosition()
Me.Calculate
End Sub



There is no such function but there is now. You must paste it to a standard
module. However, it will only update when the worksheet is calculated:

Function CPos() As String
Application.Volatile
CPos = "Cursor is in " & ActiveCell.Address(False, False)
End Function

If you need it to update when the cell selection is changed (cursor position
changes) then you need to also paste this to the worksheet's module:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Me.Calculate
End Sub

To get it to work, enter this into the desired cell:
=CPos()

Regards,
Greg

  #9   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3,365
Default Function for cursor location

Mike has given you the quick way to get into VB Editor to add a new module or
edit an existing one: [Alt]+[F11] the first time you do that in a workbook
that does not have any modules, you'll have to follow up with an Insert |
Module from the VBE menu. You can put several Sub or Functions into a single
module, you do not have to have a separate module for each Sub or Function.

If you need to ever put code into a worksheet (such as the
Worksheet_SelectionChange suggestion) - right-click on the sheet's tab and
choose [View Code] from the list presented.

"sandyboy" wrote:

I appreciate all this, but problem is, i don't know how to make a module.. :c
I'd be happy if anyone can help me about this and can refer me to a site to
know more about this.

--
sandyboy


"Mike" wrote:

Greg your right but alot of times ok most of the time ok maybe sometimes
some people worry about =CPos() getting removed

"Greg Wilson" wrote:

Mike,

We don't need to add the formula to the cell each time a cell selection is
made. By making the function volatile, it updates every time a sheet
calculation occurs, which the selection change code makes happen every time
cell selection changes. Not only is this not necessary, but hard coding it
into the event code defeats the purpose of the function - e.g. if you want to
change it to C1 then you also have to change the code. The way I have set it
up, just enter "=CPos()" in cell C1 and clear the formula in B1. Also, you
can enter the formula into multiple cells if you want.

I tested it. It works.

Regards,
Greg


"Mike" wrote:


Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Worksheets("Sheet1").Range("B2").Formula = CPosition()
Me.Calculate
End Sub



There is no such function but there is now. You must paste it to a standard
module. However, it will only update when the worksheet is calculated:

Function CPos() As String
Application.Volatile
CPos = "Cursor is in " & ActiveCell.Address(False, False)
End Function

If you need it to update when the cell selection is changed (cursor position
changes) then you need to also paste this to the worksheet's module:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Me.Calculate
End Sub

To get it to work, enter this into the desired cell:
=CPos()

Regards,
Greg

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cursor location between grouped worksheets woodyjenk Excel Discussion (Misc queries) 0 November 14th 06 07:16 PM
From Macro in Excel find cursor location eg.C7 kt(uk) Excel Discussion (Misc queries) 1 May 10th 06 03:03 PM
Cursor Location Glen Excel Discussion (Misc queries) 2 July 21st 05 09:35 PM
Is there a function that will return info of the cursor location? cbre_bryork Excel Worksheet Functions 3 May 15th 05 02:02 AM
Highlighted cell jumping to cursor location snowedin Excel Discussion (Misc queries) 0 January 19th 05 09:16 PM


All times are GMT +1. The time now is 10:09 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"