View Single Post
  #12   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Tom Hutchins Tom Hutchins is offline
external usenet poster
 
Posts: 1,069
Default Function within a cell that has a number

You are getting a circular reference because your formula in A1 is using its
own value to generate a result, which is returned to A1. This is a strange
request, but here is one way to accomplish it (without a circular reference):

The cell (A1) where you want to do this must be formatted to wrap text.

In a VBA module in your workbook, enter this user-defined function:

Function AddToCell(Value1 As Double, Value2 As Double) As String
AddToCell$ = Value1 & vbCrLf & (Value1 + Value2)
End Function

Then, call AddToCell in A1 ilke this:
=AddToCell(500,B1)
where B1 contains 100.

If you are new to user-defined functions (macros), this link to Jon
Peltier's site may be helpful:
http://peltiertech.com/WordPress/200...e-elses-macro/

Hope this helps,

Hutch

"Té" wrote:

I have 500 already in place. What I want to do is keep the number 500, then
on top of that create a formula that adds a1 and b1 together. So I want to
look like
500
600

I have 500 in a1 and 100 in b1. Does that make sense?

"Raz" wrote:

if its giving you 5000, it means its working,
i am sure u dont have any number on A1 and A2, so adding them is 0,
which is why its giving you 500 with a zero in the side, shows up as 5000.


"Té" wrote:

I just tried it on 03 and it didnt work either it returned 5000 back

"Raz" wrote:

hmm, it works fiine in mine, are you using excel 2007?

try adding brackets and quatation signs, for example
="500"&(A1+A2)


"Té" wrote:

When I tried that it said it was a circular reference and it came back 0

"Raz" wrote:

try this:
=500&A1+A2

If you want space between two then use this

=500&" "&A1+A2

You can add as many equations or text as u like, just add &

Let me know it it worked