Setting currency as string

S

Sonnich Jensen

Hi all

Is it possible to set a currency from a string?
Say I have "ABC" and want to use that as a currency?

I want to set it from VBA code

WBR
Sonnich
 
R

Ron Rosenfeld

Hi all

Is it possible to set a currency from a string?
Say I have "ABC" and want to use that as a currency?

I want to set it from VBA code

WBR
Sonnich

Just use the same format you would use on the worksheet when setting the NumberFormat property. Depending on whether you want the currency at the start or end of the numbers, maybe something like: [$ABC] #,##0_);[Red][$ABC] (#,##0)
 
S

Sonnich Jensen

Is it possible to set a currency from a string?
Say I have "ABC" and want to use that as a currency?
I want to set it from VBA code
WBR
Sonnich

Just use the same format you would use on the worksheet when setting the NumberFormat property.  Depending on whether you want the currency at thestart or end of the numbers, maybe something like:    [$ABC] #,##0_);[Red][$ABC] (#,##0)

Or

sh2.Cells(j, 2).NumberFormat = "0.00\ [$" & sh1.Cells(i, iValuuta) &
"]"
 
R

Ron Rosenfeld

Or

sh2.Cells(j, 2).NumberFormat = "0.00\ [$" & sh1.Cells(i, iValuuta) &
"]"

I cannot comment since I have no idea what is contained in sh1.Cells(i,iValuuta). I'll guess it contains "ABC" without the quotes.

I suspect, though, that the "\" is unneccessary. At least it would be unneccessary in the US version of Excel, but it doesn't hurt to have it there.
 
S

Sonnich Jensen

sh2.Cells(j, 2).NumberFormat = "0.00\ [$" & sh1.Cells(i, iValuuta) &
"]"

I cannot comment since I have no idea what is contained in sh1.Cells(i,iValuuta).  I'll guess it contains  "ABC" without the quotes.

I suspect, though, that the "\" is unneccessary.  At least it would be unneccessary in the US version of Excel, but it doesn't hurt to have it there.

SomeSheet.Cells(j, 2).NumberFormat = "0.00\ [$" & "ABC" & "]"
 
R

Ron Rosenfeld

sh2.Cells(j, 2).NumberFormat = "0.00\ [$" & sh1.Cells(i, iValuuta) &
"]"

I cannot comment since I have no idea what is contained in sh1.Cells(i,iValuuta).  I'll guess it contains  "ABC" without the quotes.

I suspect, though, that the "\" is unneccessary.  At least it would be unneccessary in the US version of Excel, but it doesn't hurt to have it there.

SomeSheet.Cells(j, 2).NumberFormat = "0.00\ [$" & "ABC" & "]"

Do you have a question? If so, please be explicit.
 

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