PC Review


Reply
Thread Tools Rate Thread

Add text with formated number using VBA

 
 
Abdul
Guest
Posts: n/a
 
      17th Mar 2007
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

 
Reply With Quote
 
 
 
 
Tom Ogilvy
Guest
Posts: n/a
 
      17th Mar 2007
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>



 
Reply With Quote
 
Tom Ogilvy
Guest
Posts: n/a
 
      17th Mar 2007
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> 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
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Transfer Text, Export Delimited w/ Number formated to 4 decimals. luchshel Microsoft Access Macros 1 24th Mar 2010 06:50 PM
Cell that is formated for Date shows a diffrent number Haider Microsoft Excel Misc 2 8th Dec 2009 08:26 PM
need to force PT to use formated number =?Utf-8?B?RGF2aWQgUnVzc2VsbA==?= Microsoft Excel Worksheet Functions 2 15th Mar 2005 11:37 PM
How do I convert a number formated as a date to text in Excel? =?Utf-8?B?QnJvdGhlck5vdg==?= Microsoft Excel Misc 5 2nd Mar 2005 03:51 PM
text boxes,grouped & formated tight,losing text when printed Knopf Microsoft Windows 2000 0 1st Aug 2003 04:18 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:46 AM.