ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   cell contents (https://www.excelbanter.com/excel-programming/338452-cell-contents.html)

kola5567[_6_]

cell contents
 

I have a cell that has a formula. The formula refrences other cells i
the sheet. I need some code that will give me the contents of a cell
select. I want it to give me the formula asigned to the cell.
Everything I have tried only gives me the value resulting from th
formula.

Ex: If a cell A1 contains "= B1+B2+B3"

I want to be able to call out this formula in come code, but I want i
to give me =B1+B2+B3, and not simple that it equals say

--
kola556
-----------------------------------------------------------------------
kola5567's Profile: http://www.excelforum.com/member.php...fo&userid=2461
View this thread: http://www.excelforum.com/showthread.php?threadid=39949


hideki[_13_]

cell contents
 

To get the formula for active cells;

Sub ShowFormula()

MsgBox ActiveCell.Formula

End Su

--
hidek
-----------------------------------------------------------------------
hideki's Profile: http://www.excelforum.com/member.php...fo&userid=1890
View this thread: http://www.excelforum.com/showthread.php?threadid=39949


kola5567[_7_]

cell contents
 

how can i use the formula in the code. For instance if I want to refer
to the last cell in the formula in another calculation. In this case I
want to say look at the formula and whatever is the last cell referenced
in the formula copy that value or something like this.


--
kola5567
------------------------------------------------------------------------
kola5567's Profile: http://www.excelforum.com/member.php...o&userid=24614
View this thread: http://www.excelforum.com/showthread...hreadid=399493


hideki[_15_]

cell contents
 

How to know the last cell referenced by looking at the formula? Is it
the right most cell in the formula or anything?


--
hideki
------------------------------------------------------------------------
hideki's Profile: http://www.excelforum.com/member.php...o&userid=18903
View this thread: http://www.excelforum.com/showthread...hreadid=399493


kola5567[_8_]

cell contents
 

What happens in the program file I have is this: data is collecte
about about defects on a part. Each defect is assigned a descriptio
and a location. For example Dent in grid location A01. This data i
then sorted and counts all the defects found in each location. Thi
count is then displayed on a picture of the part showing how man
defects were found in each location. What I want to do is be able t
select a specific location such as A01 and see how many of each defec
was written up in that location like 5 dents, 2 scratches, etc. What
was thinking of doing was allowing someone to simply select the cel
they want and click a button that would tally up the information. Thi
is because the cell refrences another sheet with the information I want
With all the ways the information can be grided, there are over 100
total cell locations so writing a program that say if A01 is selecte
do this, if A02 is selected do this would be impossible. If I ca
refer to the formula already in the cell they select, I can tell i
refer to the cell I want in the formula and it will be very easy.
Another possibility is to have a dialog box come up where someone coul
select say "full part grid" and location "A01". I don't know how to d
this with the dialog box though and then hav ewhat they select in th
box feed into the program

--
kola556
-----------------------------------------------------------------------
kola5567's Profile: http://www.excelforum.com/member.php...fo&userid=2461
View this thread: http://www.excelforum.com/showthread.php?threadid=39949


Brian

cell contents
 
Here's an approach I use:

Function FormulaText(Ref As Range) As String
FormulaText = Ref.Cells(1).Formula
End Function

"kola5567" wrote:


I have a cell that has a formula. The formula refrences other cells in
the sheet. I need some code that will give me the contents of a cell I
select. I want it to give me the formula asigned to the cell.
Everything I have tried only gives me the value resulting from the
formula.

Ex: If a cell A1 contains "= B1+B2+B3"

I want to be able to call out this formula in come code, but I want it
to give me =B1+B2+B3, and not simple that it equals say 9


--
kola5567
------------------------------------------------------------------------
kola5567's Profile: http://www.excelforum.com/member.php...o&userid=24614
View this thread: http://www.excelforum.com/showthread...hreadid=399493




All times are GMT +1. The time now is 06:08 PM.

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