Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default format text in cell

I am trying to enter distances in Excel cells and want the feet to be
normal script and the inches be in underlined superscript. Is there a
VBA code that will automatically convert the last two digits entered
into the cell? Any help will be appreciated.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default format text in cell

Sub AAA()
With ActiveCell.Characters(Len(ActiveCell.Value) - 1, 2).Font
.Superscript = True
.Underline = True
End With

End Sub

possibly. This only works with constant values - not cells containing
formulas.

--
Regards,
Tom Ogilvy




wrote in message
ups.com...
I am trying to enter distances in Excel cells and want the feet to be
normal script and the inches be in underlined superscript. Is there a
VBA code that will automatically convert the last two digits entered
into the cell? Any help will be appreciated.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 54
Default format text in cell

How do I get this only in selected cells? I have two columns (separated
by several rows) so I have 4 printable sheets. I only want the
"Measurement" cells to format this way, not the other, "Description,"
cells.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default format text in cell

Sub AAA()
for each cell in Range("A2:A20,C2:C20,D2:E20")
With Cell.Characters(Len(Cell.Value) - 1, 2).Font
.Superscript = True
.Underline = True
End With
Next
End Sub

Change the range reference to match the layout of your data.

--
Regards,
Tom Ogilvy



"L Scholes" wrote in message
oups.com...
How do I get this only in selected cells? I have two columns (separated
by several rows) so I have 4 printable sheets. I only want the
"Measurement" cells to format this way, not the other, "Description,"
cells.



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 54
Default format text in cell

I used this code in both a module and the code for Sheet1 and it
doesn't seem to have any effect.??? (When I get this sheet working I
will change the references as appropriate.)

Sub AAA()
For Each Cell In Range("C5:C59,D5:D59")
With Cell.Characters(Len(Cell.Value) - 1, 2).Font
.Superscript = True
.Underline = True
End With
Next
End Sub



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default format text in cell

This is called rich text formatting and can only be done on cells that
contain TEXT Constants (not numbers, not formulas). If your cells contain
numbers, then you would modify it to make them text as I have done below


Sub AAA()
For Each Cell In Range("C5:C59,D5:D59")
cell.Value = "'" & cell.Text
With Cell.Characters(Len(Cell.Value) - 1, 2).Font
.Superscript = True
.Underline = True
End With
Next
End Sub


--
Regards,
Tom Ogilvy

"L Scholes" wrote in message
oups.com...
I used this code in both a module and the code for Sheet1 and it
doesn't seem to have any effect.??? (When I get this sheet working I
will change the references as appropriate.)

Sub AAA()
For Each Cell In Range("C5:C59,D5:D59")
With Cell.Characters(Len(Cell.Value) - 1, 2).Font
.Superscript = True
.Underline = True
End With
Next
End Sub



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 54
Default format text in cell

I really appreciate your help, but none of this working. I made the
indicated changes on both Sheet1 and module. Am I putting the code in
the wrong place?

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default format text in cell

You have to run the code.

--
Regards,
Tom Ogilvy


"L Scholes" wrote in message
oups.com...
I really appreciate your help, but none of this working. I made the
indicated changes on both Sheet1 and module. Am I putting the code in
the wrong place?



  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 54
Default format text in cell

I used this code in both a module and the code for Sheet1 and it
doesn't seem to have any effect.??? (When I get this sheet working I
will change the references as appropriate.)

Sub AAA()
For Each Cell In Range("C5:C59,D5:D59")
With Cell.Characters(Len(Cell.Value) - 1, 2).Font
.Superscript = True
.Underline = True
End With
Next
End Sub

  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default format text in cell

What do you have stored in the cells?

--
Regards,
Tom Ogilvy

"L Scholes" wrote in message
oups.com...
I used this code in both a module and the code for Sheet1 and it
doesn't seem to have any effect.??? (When I get this sheet working I
will change the references as appropriate.)

Sub AAA()
For Each Cell In Range("C5:C59,D5:D59")
With Cell.Characters(Len(Cell.Value) - 1, 2).Font
.Superscript = True
.Underline = True
End With
Next
End Sub





  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 54
Default format text in cell

Right now there is nothing in the cells. I keep the book as a template,
then add the measurements and save the book named as a separate case
number. I can delete all macros and send you a code if that helps.

  #12   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default format text in cell

Obviously if the cell is empty, the macro will do nothing.

I already know the macro works within the constraints I cited.

If you are expecting the macro to apply a format to the cell so if you
entered something it would appear as you describe, unfortunately, Excel does
not support that. The formatting is applied directly to a text string in
the cell. An empty cell remains an empty cell.

--
Regards,
Tom Ogilvy



"L Scholes" wrote in message
oups.com...
Right now there is nothing in the cells. I keep the book as a template,
then add the measurements and save the book named as a separate case
number. I can delete all macros and send you a code if that helps.



  #13   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 54
Default format text in cell

The cells are empty when I start, but I add the measurements, feet and
inches, as the information becomes available. Now I have to insert the
numbers, then select the inches portion (last two digits), right click,
select "Format Cells""Font," then select "superscript," and
"underline." There is no way to do this automatically using a macro?
Some of these measurements run into the thousands.

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
word match in string text in cell, color format cell jpmahony Excel Discussion (Misc queries) 1 October 31st 07 03:56 PM
Compare text in cell to custom text format?? Tommy[_4_] Excel Discussion (Misc queries) 1 July 20th 07 02:45 PM
Can not see text in Excel when cell format is set to wrap text Mark New Users to Excel 1 May 29th 07 02:07 PM
Making cell reference absolute makes cell format text Excel Worksheet Functions 2 September 22nd 06 04:47 PM
Format text in cell from XY to X-Y ELS Excel Discussion (Misc queries) 3 April 25th 06 12:25 AM


All times are GMT +1. The time now is 10:32 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"