Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How do I programmatically know the current cell's address


Question:
Given a formula, say f(x), assigned to any given cell, c
(n,m), I need to know n and m. Can any one help me?

Thanks

kc
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 493
Default How do I programmatically know the current cell's address

Not sure what your given f(x) has to do with it, but you can find
the row and column numbers for any cell as

Dim n As Long
Dim m As Integer
Dim cell As Range
Set cell = <given cell
With cell
n = .Row
m = .Column
End With


If you're talking about worksheet functions instead of programming,
then for f(x) = SUM(n, m):

=SUM(ROW(),COLUMN())

will give the sum of the row number and column number.

In article ,
"Keith" wrote:

Question:
Given a formula, say f(x), assigned to any given cell, c
(n,m), I need to know n and m. Can any one help me?

Thanks

kc

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default How do I programmatically know the current cell's address

Another possibility

Sub TestPrecedents()
Range("A1").Formula = "=C9^2"
Set rng = Range("A1").DirectPrecedents
MsgBox rng(1).Address & " row: " & rng(1).Row & _
" col: " & rng(1).Column

End Sub



--
Regards,
Tom Ogilvy

"J.E. McGimpsey" wrote in message
...
Not sure what your given f(x) has to do with it, but you can find
the row and column numbers for any cell as

Dim n As Long
Dim m As Integer
Dim cell As Range
Set cell = <given cell
With cell
n = .Row
m = .Column
End With


If you're talking about worksheet functions instead of programming,
then for f(x) = SUM(n, m):

=SUM(ROW(),COLUMN())

will give the sum of the row number and column number.

In article ,
"Keith" wrote:

Question:
Given a formula, say f(x), assigned to any given cell, c
(n,m), I need to know n and m. Can any one help me?

Thanks

kc



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default How do I programmatically know the current cell's address

If you put

=f(x)

in a cell and have UDF

Public function f( x as Range)
set rng = application.Caller


End function

Then rng will contain a range reference to the cell containing the =f(x)
which as fired the Function for calculation.

--
Regards,
Tom Ogilvy


"Keith" wrote in message
...
To clarify f(x):

f(x) will be the sum of two cells in columns located to
the left of the current cell and x number of rows up + all
of the cells in the current column and current row for x
number of rows. x is user definable and dynamic.

x is the leadtime in days of the receipt of product the
two columns to the left of the current cell are the daily
on hand quantities (OHQ) and daily issues (I) of the
product. When the sum of the OHQ - I + the sum of all
receipts during the present defined leadtime fall below a
lower limit, f(x) will return a new receipt.

I am modeling a purchasing system to allow our percurment
people visiblility of several system defined variables.

Hope this helps.

kc

-----Original Message-----
Not sure what your given f(x) has to do with it, but you

can find
the row and column numbers for any cell as

Dim n As Long
Dim m As Integer
Dim cell As Range
Set cell = <given cell
With cell
n = .Row
m = .Column
End With


If you're talking about worksheet functions instead of

programming,
then for f(x) = SUM(n, m):

=SUM(ROW(),COLUMN())

will give the sum of the row number and column number.

In article ,
"Keith" wrote:

Question:
Given a formula, say f(x), assigned to any given

cell, c
(n,m), I need to know n and m. Can any one help me?

Thanks

kc

.



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
Change another cell's contents from current cell??? HandsomeJake Excel Discussion (Misc queries) 1 March 12th 07 12:42 AM
cell's address of the largest number novio Excel Discussion (Misc queries) 1 April 9th 05 10:16 PM
How can I change a text to a cell's address? Antônio Sobral Excel Discussion (Misc queries) 0 February 15th 05 04:55 PM
Change cell's WIDTH programmatically Marat Excel Programming 1 August 27th 03 03:31 PM
Change cell's WIDTH programmatically Marat Excel Programming 0 August 27th 03 03:23 PM


All times are GMT +1. The time now is 11:05 PM.

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

About Us

"It's about Microsoft Excel"