Using functions in string formatted cells

R

Robert Crandal

I created my own function in Module1 which looks as follows:

Public Function Foo (ByVal strData as String)

Foo = "Hello World!" ' Return basic string

End Function


On my actual spreadsheet, cell "A1" is formatted as a "text"
type cell, there I cannot simply plug in my Foo() function
into cell "A1". I tried putting the following value into
cell "A1":

=Foo(A1)

If i enter that formula into cell A1 (which is a text cell), then
Excel will simply enter the above formula as a string, instread
of running the function.

So I guess my question is, how can I enter formulas into
cells that are formatted as "text"??

thank you
 
B

Bob Phillips

It is nothing to do with being formatted as text. You cannot have a function
and a value in a cell, one or the other.

So you can have a value in A1 and put this in A2, =Foo(A1), but not what you
are trying to do.
 
R

Rob van Gelder

Just set the format to General. If a string is returned from the function, such as 0123, it will display 0123 instead of 123.
 
G

Gord Dibben

You cannot.

Why are the cells cell formatted as text?

Can you not change to General or some other format?


Gord Dibben MS Excel MVP
 
G

Gord Dibben

Missed the circ ref problem but that would become apparent only if the cell
were not formatted as text.


Gord
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top