Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Getting the formula of a cell as text

Hi,
I want to create a macro that puts the cursor over a cell which is
retrieved from the cell it's standing on.
Wow, I notice english is not my first language, because even I can't
really understand what I just wrote :)

An example would be better.

Let's say I'm standing on a cell with the formula "=A25".
Now when I'm standing on this cell I want to run a macro that moves
the cursor over the referenced cell (A25).

Now I can go to a cell if I have the position of the cell as text in
the current cell as:

Range(Activecell.Value).Select

How can I achieve this to replace Activecell.value with the text
gotten from the formula?

TIA
Regards,
--
Beto
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Getting the formula of a cell as text

Try something like this

x = Mid(Selection.Formula, 2, Len(Selection.Formula))
Range(x).Select



--

"Beto" wrote in message
om...
Hi,
I want to create a macro that puts the cursor over a cell which is
retrieved from the cell it's standing on.
Wow, I notice english is not my first language, because even I can't
really understand what I just wrote :)

An example would be better.

Let's say I'm standing on a cell with the formula "=A25".
Now when I'm standing on this cell I want to run a macro that moves
the cursor over the referenced cell (A25).

Now I can go to a cell if I have the position of the cell as text in
the current cell as:

Range(Activecell.Value).Select

How can I achieve this to replace Activecell.value with the text
gotten from the formula?

TIA
Regards,
--
Beto



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Getting the formula of a cell as text

Actually It should be directprecedents - precendents includes more than
directprecedents.

Sub MoveTo()
Dim rng As Range
If ActiveCell.HasFormula Then
On Error Resume Next
Set rng = ActiveCell.DirectPrecedents
On Error GoTo 0
If Not rng Is Nothing Then
rng.Areas(1).Select
End If
End If
End Sub

--
Regards,
Tom Ogilvy

Tom Ogilvy wrote in message
...
Assuming you are not trying to move to another sheet:

Sub MoveTo()
Dim rng As Range
If ActiveCell.HasFormula Then
On Error Resume Next
Set rng = ActiveCell.Precedents
On Error GoTo 0
If Not rng Is Nothing Then
rng.Areas(1).Select
End If
End If
End Sub


--
Regards,
Tom Ogilvy



Beto wrote in message
om...
Hi,
I want to create a macro that puts the cursor over a cell which is
retrieved from the cell it's standing on.
Wow, I notice english is not my first language, because even I can't
really understand what I just wrote :)

An example would be better.

Let's say I'm standing on a cell with the formula "=A25".
Now when I'm standing on this cell I want to run a macro that moves
the cursor over the referenced cell (A25).

Now I can go to a cell if I have the position of the cell as text in
the current cell as:

Range(Activecell.Value).Select

How can I achieve this to replace Activecell.value with the text
gotten from the formula?

TIA
Regards,
--
Beto





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default Getting the formula of a cell as text

Hello Beto

A similar solution to Tom's is:

Sub MyIndirect()
Dim Cell As Range
Dim s As String
If ActiveCell.HasFormula = False Then
MsgBox "There is no formula in this cell", , "Error_
Alert"
Exit Sub
Else: s = "" & ActiveCell.Formula & ""
Range(s).Select
End If
End Sub

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Getting the formula of a cell as text

Thanks to all who answered. I'll try the solutions soon!

Regards,
--
Beto

"Peter Atherton" wrote in message ...
Hello Beto

A similar solution to Tom's is:

Sub MyIndirect()
Dim Cell As Range
Dim s As String
If ActiveCell.HasFormula = False Then
MsgBox "There is no formula in this cell", , "Error_
Alert"
Exit Sub
Else: s = "" & ActiveCell.Formula & ""
Range(s).Select
End If
End Sub

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
bold text of referenced cell show in formula cell zabcikranch Excel Worksheet Functions 1 February 2nd 10 07:42 PM
The result of a formula referring to a cell with formula as text? JCC Excel Worksheet Functions 10 September 3rd 09 03:15 PM
Concatenate text cell and formula cell result GoinCrazy Excel Worksheet Functions 4 November 26th 08 04:27 PM
Excel Formula if cell is empty then no if text in cell then yes Kathy Excel Worksheet Functions 2 December 20th 06 05:24 PM
match cell text with text in formula Todd L. Excel Worksheet Functions 3 December 9th 04 08:11 PM


All times are GMT +1. The time now is 07:34 AM.

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"