Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 86
Default IF Function - Specific currency format

Hello,

How do I write a function that only returns a value if the cell (A1) is of
the currency Euro. I assume the If function would be used. Here is what i
want it do.

=IF(A1 is currency EURO, *0.61,"")

I'm not sure if the TYPE or CELL function is used with it or another function.

Many thanks,
--
Thank you,

Colin.
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11,058
Default IF Function - Specific currency format

First enter this tiny UDF:

Function txet(r As Range) As String
txet = ""
If r.Count = 1 Then
txet = r.Text
End If
End Function

This function returns a text string that matches the "as seen" value. This
means that if A1 contains:
‚¬ 12.34
then =Txet(A1) will have the Euro symbol as its first character. Then we
can test that first character:


=IF(LEFT(txet(A1),1)="‚¬","*.61","")

Have a very pleasant weekend.
--
Gary''s Student - gsnu200713


"Colin" wrote:

Hello,

How do I write a function that only returns a value if the cell (A1) is of
the currency Euro. I assume the If function would be used. Here is what i
want it do.

=IF(A1 is currency EURO, *0.61,"")

I'm not sure if the TYPE or CELL function is used with it or another function.

Many thanks,
--
Thank you,

Colin.

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 4,393
Default IF Function - Specific currency format

Interesting UDF. Thanks for this.
I tried it with cells formatted Currency with $, £, and ? and
LEFT(txet(A1),1) worked
But with Accounting, you need to test =MID(txet(A1),2,1)
best wishes
--
Bernard V Liengme
www.stfx.ca/people/bliengme
remove caps from email

"Gary''s Student" wrote in message
...
First enter this tiny UDF:

Function txet(r As Range) As String
txet = ""
If r.Count = 1 Then
txet = r.Text
End If
End Function

This function returns a text string that matches the "as seen" value.
This
means that if A1 contains:
? 12.34
then =Txet(A1) will have the Euro symbol as its first character. Then we
can test that first character:


=IF(LEFT(txet(A1),1)="?","*.61","")

Have a very pleasant weekend.
--
Gary''s Student - gsnu200713


"Colin" wrote:

Hello,

How do I write a function that only returns a value if the cell (A1) is
of
the currency Euro. I assume the If function would be used. Here is what i
want it do.

=IF(A1 is currency EURO, *0.61,"")

I'm not sure if the TYPE or CELL function is used with it or another
function.

Many thanks,
--
Thank you,

Colin.



  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11,058
Default IF Function - Specific currency format

You are welcome. I don't often use this feature, but sometimes in VBA I use
rng.Text to get the cell contents "as displayed"
--
Gary''s Student - gsnu200714


"Bernard Liengme" wrote:

Interesting UDF. Thanks for this.
I tried it with cells formatted Currency with $, £, and ? and
LEFT(txet(A1),1) worked
But with Accounting, you need to test =MID(txet(A1),2,1)
best wishes
--
Bernard V Liengme
www.stfx.ca/people/bliengme
remove caps from email

"Gary''s Student" wrote in message
...
First enter this tiny UDF:

Function txet(r As Range) As String
txet = ""
If r.Count = 1 Then
txet = r.Text
End If
End Function

This function returns a text string that matches the "as seen" value.
This
means that if A1 contains:
? 12.34
then =Txet(A1) will have the Euro symbol as its first character. Then we
can test that first character:


=IF(LEFT(txet(A1),1)="?","*.61","")

Have a very pleasant weekend.
--
Gary''s Student - gsnu200713


"Colin" wrote:

Hello,

How do I write a function that only returns a value if the cell (A1) is
of
the currency Euro. I assume the If function would be used. Here is what i
want it do.

=IF(A1 is currency EURO, *0.61,"")

I'm not sure if the TYPE or CELL function is used with it or another
function.

Many thanks,
--
Thank you,

Colin.




  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 86
Default IF Function - Specific currency format

Hello,

Thank you for your response.

If I understand this correctly, I paste your UDF (What does this mean?) code
into the VBA code window of the spreadsheet that holds the information I want
to use this code with. I have not added anything else to this code in the
code window. The dropdown above the code window now shows 'general' on the
left and 'txet' in the right one.

I then pasted the function into the appropiate cell in the spreadsheet but
then Excel shows the NAME error in the cell.
The reference cell (A1) is formatted for currency with the Euro symbol.

I have not put the code into its own module or anything.

What am I doing wrong?
--
Thank you,

Colin.


"Gary''s Student" wrote:

You are welcome. I don't often use this feature, but sometimes in VBA I use
rng.Text to get the cell contents "as displayed"
--
Gary''s Student - gsnu200714


"Bernard Liengme" wrote:

Interesting UDF. Thanks for this.
I tried it with cells formatted Currency with $, £, and ? and
LEFT(txet(A1),1) worked
But with Accounting, you need to test =MID(txet(A1),2,1)
best wishes
--
Bernard V Liengme
www.stfx.ca/people/bliengme
remove caps from email

"Gary''s Student" wrote in message
...
First enter this tiny UDF:

Function txet(r As Range) As String
txet = ""
If r.Count = 1 Then
txet = r.Text
End If
End Function

This function returns a text string that matches the "as seen" value.
This
means that if A1 contains:
? 12.34
then =Txet(A1) will have the Euro symbol as its first character. Then we
can test that first character:


=IF(LEFT(txet(A1),1)="?","*.61","")

Have a very pleasant weekend.
--
Gary''s Student - gsnu200713


"Colin" wrote:

Hello,

How do I write a function that only returns a value if the cell (A1) is
of
the currency Euro. I assume the If function would be used. Here is what i
want it do.

=IF(A1 is currency EURO, *0.61,"")

I'm not sure if the TYPE or CELL function is used with it or another
function.

Many thanks,
--
Thank you,

Colin.






  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11,058
Default IF Function - Specific currency format

The error message says that Excel can't find the function. This usually
means its not in the correct place:


User Defined Functions (UDFs) are very easy to install and use:

1. ALT-F11 brings up the VBE window
2. ALT-I
ALT-M opens a fresh module
3. paste the UDF in and close the VBE window

If you save the workbook, the UDF will be saved with it.

To remove the UDF:

1. bring up the VBE window as above
2. clear the code out
3. close the VBE window

To learn more about UDFs and macros in general, see:

http://www.mvps.org/dmcritchie/excel/getstarted.htm


Update this post if more problems occur...
--
Gary''s Student - gsnu200715
  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1,231
Default IF Function - Specific currency format

Colin wrote...
....
If I understand this correctly, I paste your UDF (What does this
mean?) . . .


UDF is the acronym for user-defined function.

. . . code into the VBA code window of the spreadsheet that holds
the information I want to use this code with. . . .

....
I have not put the code into its own module or anything.

What am I doing wrong?

....

You need to put udfs into so-called general VBA modules, i. e., you
need to put the code into its own module.

Switch to the Visual Basic Editor (VBE) by pressing [Alt]+[F11], then
run the VBE menu command Insert Module to create a new, blank
general module, and paste the udf code into it.

Since Excel provides many different Euro number formats, the key seems
to be the presence of the Euro symbol ‚¬ somewhere in the cell's
display (.Text property). And udfs that vary with cell formatting
should be volatile so they recalc more often, so pick up formatting
changes more frequently.

Anyway, the most general way to use the proposed txet udf would be

=IF(COUNT(X99,FIND("‚¬",txet(X99)))=2,"*0.61","")

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
Format Currency Send Object Command - Two attachments Excel Discussion (Misc queries) 1 November 10th 05 04:44 PM
format cells for currency 2450 and have it format to $24.50? Karen C Excel Worksheet Functions 0 October 13th 05 03:21 PM
Change General Format to Currency Format Freshman Excel Worksheet Functions 3 July 8th 05 03:42 AM
Currency format Samir Kapadia Excel Worksheet Functions 6 June 23rd 05 11:55 AM
why does currency format change to number format? Cassie Excel Discussion (Misc queries) 3 March 18th 05 06:57 PM


All times are GMT +1. The time now is 05:28 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"