Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Special string formatting

Am using a excel report generator which works with excel template file
Have a cell in the template file which is referred to as Grid_Value
This cell is populated with a string representing cubic meters o
water i.e
203.34M3
How can the field be formatted in vba to show 203.34 M (superscript)

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Special string formatting

I don't think that you can format a cell to show
super/sub scripted characters. However, you can edit the
text to do thiis, but you'll lose the formula.
Here's a test example which should show how



Sub test()

Range("B2").Value = "2,45M3"

showcubed Range("B2")

End Sub
Function showcubed(ByRef target As Range)
'
'sets the last character to superscript
'
Dim length As Long
length = Len(target.Value)

With target.Characters(Start:=length, length:=1).Font
.Superscript = True
End With

End Function


Patrick Molloy
Microsoft Excel MVP
-----Original Message-----
Am using a excel report generator which works with excel

template file.
Have a cell in the template file which is referred to

as Grid_Value.
This cell is populated with a string representing cubic

meters of
water i.e
203.34M3
How can the field be formatted in vba to show 203.34 M

(superscript)3


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

.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Special string formatting

Hello Christobal
With Range(Grid_Value).Characters(8, 1).Font
.Superscript = True
End With
HTH
Regards
Pascal

"christobal " a écrit dans le
message de news: ...
Am using a excel report generator which works with excel template file.
Have a cell in the template file which is referred to as Grid_Value.
This cell is populated with a string representing cubic meters of
water i.e
203.34M3
How can the field be formatted in vba to show 203.34 M (superscript)3


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



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Special string formatting

Sub test()

Range("B2").Value = "2,45M3"

showcubed Range("B2")

End Sub
Function showcubed(ByRef target As Range)
'
'sets the last character to superscript
'
Dim length As Long
length = Len(target.Value)

With target.Characters(Start:=length, length:=1).Font
.Superscript = True
End With

End Function

This is good for a single cell.
The report generator enters numerous rows into an unbound range who
4th column is represented by Grid_Value. The String is of no fixe
lengt

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

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Special string formatting

christobal wrote in message ...
Am using a excel report generator which works with excel template file.
Have a cell in the template file which is referred to as Grid_Value.
This cell is populated with a string representing cubic meters of
water i.e
203.34M3
How can the field be formatted in vba to show 203.34 M (superscript)3


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


The ³ of M³ is actually available as a character in its own right
(Check Character map or copy from this message) - therefore suggest
one solution is to define ...
..
Const Mcub As String = " M³"
..
Locate the cell containing your string and then ...
..
ActiveCell.Value = Left(ActiveCell.Value,Len(Activecell.Value)-2) &
Mcub
..
Regards ...


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 136
Default Special string formatting

Try format-cells-custom
then in the Type box enter the following:
0.00" M³"
Note that you enter the superscript 3 as Alt 0179 and you must use the
numeric keys of the keypad.
(On a laptop, this may be the only time you ever use the NumLk key)

christobal < wrote:
Am using a excel report generator which works with excel template file.
Have a cell in the template file which is referred to as Grid_Value.
This cell is populated with a string representing cubic meters of
water i.e
203.34M3
How can the field be formatted in vba to show 203.34 M (superscript)3


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

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 136
Default Special string formatting

In VBA:
ActiveCell.NumberFormat = "0.00 ""M³"""
Again, you must use the numeric key pad and Alt0179 while in the VBA
code editor.

christobal < wrote:

Am using a excel report generator which works with excel template file.
Have a cell in the template file which is referred to as Grid_Value.
This cell is populated with a string representing cubic meters of
water i.e
203.34M3
How can the field be formatted in vba to show 203.34 M (superscript)3


---
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
special formatting? jim sturtz Excel Worksheet Functions 3 September 18th 06 04:31 PM
remove special character at end of string captain bob Excel Discussion (Misc queries) 0 August 3rd 06 02:59 PM
How do you count (not sum) cells containing special formatting? tbank Excel Worksheet Functions 1 October 12th 05 10:13 PM
Special cell formatting Sunshine Excel Discussion (Misc queries) 2 April 7th 05 10:05 PM
Escape for special characters in string Jag Man Excel Programming 2 January 2nd 04 03:56 AM


All times are GMT +1. The time now is 12:34 AM.

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"