Add text with formated number using VBA

  • Thread starter Thread starter Abdul
  • Start date Start date
A

Abdul

Hello,

Is it possible to add a text with number using vba and format that
number to "[$-2000000]#0"

Something like Range("A1")= "Sample Text " & format(12345,
"[$-2000000]#0")

If add 12345 to Range A1 and say

Range("A1").numberformat="[$-2000000]#0" then it works properly

Thanks
 
Format doesn't seem to recognize that format, but this is close:

Sub AAA()
s = "This is sample text: "
For i = 1 To 5
s = s & ChrW(1776 + i)
Next
ActiveCell.Value = s
ActiveCell.Characters(22, 5).Font.Name = "Lucidia Sans Unicode"
End Sub

Change Lucidia Sans Unicode to a Unicode font on your system.
I don't know the arabic symbols, so this didn't exactly match what the
number format produces for the numbers 4 and 5. 1, 2 and 3 seemed to match.
Maybe you can see how to correct it.
 
In Excel 2003 on Windows XP, Arial appears to be unicode, so you don't need
the last line if yours is unicode (there used to be a special Arial Unicode
font in Windows 98 and maybe 2000 as I recall):

Sub AAA()
s = "This is sample text: "
For i = 1 To 5
s = s & ChrW(1776 + i)
Next
ActiveCell.Value = s
End Sub

--
Regards,
Tom Ogilvy




Tom Ogilvy said:
Format doesn't seem to recognize that format, but this is close:

Sub AAA()
s = "This is sample text: "
For i = 1 To 5
s = s & ChrW(1776 + i)
Next
ActiveCell.Value = s
ActiveCell.Characters(22, 5).Font.Name = "Lucidia Sans Unicode"
End Sub

Change Lucidia Sans Unicode to a Unicode font on your system.
I don't know the arabic symbols, so this didn't exactly match what the
number format produces for the numbers 4 and 5. 1, 2 and 3 seemed to
match. Maybe you can see how to correct it.

--
Regards,
Tom Ogilvy

Abdul said:
Hello,

Is it possible to add a text with number using vba and format that
number to "[$-2000000]#0"

Something like Range("A1")= "Sample Text " & format(12345,
"[$-2000000]#0")

If add 12345 to Range A1 and say

Range("A1").numberformat="[$-2000000]#0" then it works properly

Thanks
 

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

Back
Top