Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Passing format to variable Part 2

I am passing a currenct number format to a variable and using applying
this format to a range. The number formats themselves are driven by a
Case Statement. If the currency chosen equals one of five specific
currencies I pass one of 5 specific formats to a variable. I want to
put a 6th condition in the Case Statement that says, If the currency
equal something other than the five prescribed Cases, then pass the
text string into the format itself. I am using a Case Else statement
for this 6th condition. I just do not know how to incorpoate the
variable "Currencies" into the format string. Does anyone know how to
do this?

See below:

Select Case Currencies
Case Is = "USD"
CurrencyFormat = "$""US"" #,##0_);[Red]($#,##0)"

Case Is = "CDN"
CurrencyFormat = "$""CDN"" #,##0_);[Red]($#,##0)"

Case Is = "GBP"
CurrencyFormat = "£ #,##0_);[Red]($#,##0)"

Case Is = "Euros"
CurrencyFormat = "€ #,##0_);[Red]($#,##0)"

Case Is = "Yen"
CurrencyFormat = "¥ #,##0_);[Red]($#,##0)"

Case Else
CurrencyFormat = Currencies & " #,##0_);[Red]($#,##0)"

End Select


---
Message posted from http://www.ExcelForum.com/

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 811
Default Passing format to variable Part 2


Because the value in the Currencies variable is a literal string you
have to surround it in double quotes just as you would any other literal
string in order to get it into a number format. Here's an example:

Case Else
CurrencyFormat = """" & Currencies & """ #,##0_);[Red]($#,##0)"

--
Rob Bovey, MCSE, MCSD, Excel MVP
Application Professionals
http://www.appspro.com/

* Please post all replies to this newsgroup *
* I delete all unsolicited e-mail responses *


"ExcelMonkey " wrote in message
...
I am passing a currenct number format to a variable and using applying
this format to a range. The number formats themselves are driven by a
Case Statement. If the currency chosen equals one of five specific
currencies I pass one of 5 specific formats to a variable. I want to
put a 6th condition in the Case Statement that says, If the currency
equal something other than the five prescribed Cases, then pass the
text string into the format itself. I am using a Case Else statement
for this 6th condition. I just do not know how to incorpoate the
variable "Currencies" into the format string. Does anyone know how to
do this?

See below:

Select Case Currencies
Case Is = "USD"
CurrencyFormat = "$""US"" #,##0_);[Red]($#,##0)"

Case Is = "CDN"
CurrencyFormat = "$""CDN"" #,##0_);[Red]($#,##0)"

Case Is = "GBP"
CurrencyFormat = "£ #,##0_);[Red]($#,##0)"

Case Is = "Euros"
CurrencyFormat = "? #,##0_);[Red]($#,##0)"

Case Is = "Yen"
CurrencyFormat = "¥ #,##0_);[Red]($#,##0)"

Case Else
CurrencyFormat = Currencies & " #,##0_);[Red]($#,##0)"

End Select


---
Message posted from http://www.ExcelForum.com/



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
Passing Variable to LINEST RW Excel Worksheet Functions 5 May 24th 05 07:00 PM
Passing Number Format to a Variable ExcelMonkey[_133_] Excel Programming 13 June 7th 04 04:40 AM
passing variable to file... Ernst Guckel[_2_] Excel Programming 1 June 2nd 04 05:46 PM
Passing a variable between workbooks Rich Cooper Excel Programming 1 May 19th 04 07:27 PM
Passing variable from one sub to another Medemper Excel Programming 0 February 26th 04 10:23 PM


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