Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Show formula in cell

I'm using Excel XP. When I enter a formula (sum, vlookup,
sumif, etc.) in cell A1, I'd like cell A2 to show the
actual formula text. So, A1 will show the results of the
formula, while A2 shows the actual formula itself.

So, for example, if cell C1=1 and cell C2=2 and I type
into A1 "=SUM(C1:C2)" the results will be as follows:

Cell A1 will show the result: 3
Cell A2 will show the formula text: "=SUM(C1:C2)"

I'm thinking there should be a way in VBA to return the
formula text somehow. I just don't know how to do it.

Thanks for any and all help.

C.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Show formula in cell

Craig,
Here is something that I got to work just messing around with it. There
might be a better way though.

Private Sub Workbook_SheetCalculate(ByVal Sh As Object)
Cells(1, 2) = "'" & Worksheets("sheet1").Range("a1").Formula
End Sub

Hope this helps

Charlie

"Craig" wrote in message
...
I'm using Excel XP. When I enter a formula (sum, vlookup,
sumif, etc.) in cell A1, I'd like cell A2 to show the
actual formula text. So, A1 will show the results of the
formula, while A2 shows the actual formula itself.

So, for example, if cell C1=1 and cell C2=2 and I type
into A1 "=SUM(C1:C2)" the results will be as follows:

Cell A1 will show the result: 3
Cell A2 will show the formula text: "=SUM(C1:C2)"

I'm thinking there should be a way in VBA to return the
formula text somehow. I just don't know how to do it.

Thanks for any and all help.

C.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,236
Default Show formula in cell

Public Function FormulaText(rng As Range) As String
FormulaText = rng.Formula
End Function

Then in A2: =FormulaText(A1)

--
Rob van Gelder - http://www.vangelder.co.nz/excel


"Craig" wrote in message
...
I'm using Excel XP. When I enter a formula (sum, vlookup,
sumif, etc.) in cell A1, I'd like cell A2 to show the
actual formula text. So, A1 will show the results of the
formula, while A2 shows the actual formula itself.

So, for example, if cell C1=1 and cell C2=2 and I type
into A1 "=SUM(C1:C2)" the results will be as follows:

Cell A1 will show the result: 3
Cell A2 will show the formula text: "=SUM(C1:C2)"

I'm thinking there should be a way in VBA to return the
formula text somehow. I just don't know how to do it.

Thanks for any and all help.

C.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Show formula in cell

In the worksheet's code area:

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target(1, 1), _
Range("A1")) Is Nothing Then
Target.Offset(, 1).Value = _
"'" & Target.Formula
End If
End Sub


"Craig" wrote in message
...
I'm using Excel XP. When I enter a formula (sum, vlookup,
sumif, etc.) in cell A1, I'd like cell A2 to show the
actual formula text. So, A1 will show the results of the
formula, while A2 shows the actual formula itself.

So, for example, if cell C1=1 and cell C2=2 and I type
into A1 "=SUM(C1:C2)" the results will be as follows:

Cell A1 will show the result: 3
Cell A2 will show the formula text: "=SUM(C1:C2)"

I'm thinking there should be a way in VBA to return the
formula text somehow. I just don't know how to do it.

Thanks for any and all help.

C.



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Show formula in cell

slight change

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target(1, 1), _
Range("A1")) Is Nothing Then
Target(1, 1).Offset(, 1).Value = _
"'" & Target(1, 1).Formula
End If
End Sub

"Tim Zych" wrote in message
...
In the worksheet's code area:

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target(1, 1), _
Range("A1")) Is Nothing Then
Target.Offset(, 1).Value = _
"'" & Target.Formula
End If
End Sub


"Craig" wrote in message
...
I'm using Excel XP. When I enter a formula (sum, vlookup,
sumif, etc.) in cell A1, I'd like cell A2 to show the
actual formula text. So, A1 will show the results of the
formula, while A2 shows the actual formula itself.

So, for example, if cell C1=1 and cell C2=2 and I type
into A1 "=SUM(C1:C2)" the results will be as follows:

Cell A1 will show the result: 3
Cell A2 will show the formula text: "=SUM(C1:C2)"

I'm thinking there should be a way in VBA to return the
formula text somehow. I just don't know how to do it.

Thanks for any and all help.

C.







  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 691
Default Show formula in cell

I have a page on the topic, with some variations
GetFormula (similar to Ron's), GetFormulaD, GetFormat, etc.

Show FORMULA or FORMAT of another cell
http://www.mvps.org/dmcritchie/excel/formula.htm
--
HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"Rob van Gelder" wrote ...
Public Function FormulaText(rng As Range) As String
FormulaText = rng.Formula
End Function

Then in A2: =FormulaText(A1)

--
Rob van Gelder - http://www.vangelder.co.nz/excel


"Craig" wrote in message
...
I'm using Excel XP. When I enter a formula (sum, vlookup,
sumif, etc.) in cell A1, I'd like cell A2 to show the
actual formula text. So, A1 will show the results of the
formula, while A2 shows the actual formula itself.

So, for example, if cell C1=1 and cell C2=2 and I type
into A1 "=SUM(C1:C2)" the results will be as follows:

Cell A1 will show the result: 3
Cell A2 will show the formula text: "=SUM(C1:C2)"

I'm thinking there should be a way in VBA to return the
formula text somehow. I just don't know how to do it.

Thanks for any and all help.

C.





  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Show formula in cell

Thanks for all your help!

-----Original Message-----
I'm using Excel XP. When I enter a formula (sum,

vlookup,
sumif, etc.) in cell A1, I'd like cell A2 to show the
actual formula text. So, A1 will show the results of the
formula, while A2 shows the actual formula itself.

So, for example, if cell C1=1 and cell C2=2 and I type
into A1 "=SUM(C1:C2)" the results will be as follows:

Cell A1 will show the result: 3
Cell A2 will show the formula text: "=SUM(C1:C2)"

I'm thinking there should be a way in VBA to return the
formula text somehow. I just don't know how to do it.

Thanks for any and all help.

C.
.

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
need sum to show instead of formula in cell Linda Excel Discussion (Misc queries) 2 January 24th 06 04:24 PM
How to show the formula of another cell Bol Excel Worksheet Functions 2 January 2nd 06 02:34 PM
I want the results of a formula to show in cell, NOT THE FORMULA! ocbecky Excel Discussion (Misc queries) 4 December 10th 04 08:39 PM
Cell doesn't show formula result - it shows formula (CTRL + ' doe. o0o0o0o Excel Worksheet Functions 6 November 19th 04 03:13 PM


All times are GMT +1. The time now is 11:33 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"