Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Superscript Registered symbol

I'm creating acombination of worksheets that will allow me to generate a
printable report page, based on technical and non-technical information input
on a collecting worksheet. Depending on my selections/answers, information
will be copied, displayed, hidden, etc. Some of my information includes the
registered symbol, ®, but I want it to be in superscript. Originally I
formatted the character in the source cells, but only the contents are copied
by my formulas, not the formats. I tried the following macro, to no avail:

Sub FancyR()
With Application.ReplaceFormat.Font
.Superscript = True
.Subscript = False
End With
Cells.Replace What:="®", Replacement:="®", LookAt:=xlPart, SearchOrder _
:=xlByRows, MatchCase:=False, SearchFormat:=False, ReplaceFormat:=True
End Sub

This macro simply finds an instance and superscripts the entire cell.
That's definitely not what I was intending. Also, it doesn't find the symbol
in any of the cells that have been copied, so they're completely untouched.
Any suggestions? Or, can this even be done?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Superscript Registered symbol

If the cells that aren't working are formulas, then that's the way excel works.
If the cells are numeric and just show the (R) symbol because of formatting,
then that's the way excel works.

But if the cells are text and actually contain those symbols, you're going to
have to dump the "Replace All" technique and loop through the cells--and loop
through the value in the cells (if the cell has multiple (R) symbols).

This worked ok for me:

Option Explicit
Sub FancyR()

Dim RegTM As String
Dim FirstAddress As String
Dim FoundCell As Range
Dim wks As Worksheet
Dim HowMany As Long
Dim iPos As Long
Dim StartPos As Long

RegTM = Chr(174) '®

Set wks = Worksheets("sheet1")

With wks
With .Cells
Set FoundCell = .Find(what:=RegTM, after:=.Cells(.Cells.Count), _
LookIn:=xlValues, lookat:=xlPart, _
searchorder:=xlByRows, _
MatchCase:=False, searchdirection:=xlNext)

If FoundCell Is Nothing Then
MsgBox RegTM & " not found!"
Exit Sub
End If

FirstAddress = FoundCell.Address

Do
StartPos = 1
Do
iPos _
= InStr(StartPos, FoundCell.Value, RegTM, vbTextCompare)
If iPos = 0 Then
Exit Do
End If
FoundCell.Characters(Start:=iPos, Length:=1) _
.Font.Superscript = True
StartPos = iPos + 1
Loop

Set FoundCell = .FindNext(after:=FoundCell)

If FoundCell.Address = FirstAddress Then
Exit Do
End If

Loop

End With
End With
End Sub

Christopher wrote:

I'm creating acombination of worksheets that will allow me to generate a
printable report page, based on technical and non-technical information input
on a collecting worksheet. Depending on my selections/answers, information
will be copied, displayed, hidden, etc. Some of my information includes the
registered symbol, ®, but I want it to be in superscript. Originally I
formatted the character in the source cells, but only the contents are copied
by my formulas, not the formats. I tried the following macro, to no avail:

Sub FancyR()
With Application.ReplaceFormat.Font
.Superscript = True
.Subscript = False
End With
Cells.Replace What:="®", Replacement:="®", LookAt:=xlPart, SearchOrder _
:=xlByRows, MatchCase:=False, SearchFormat:=False, ReplaceFormat:=True
End Sub

This macro simply finds an instance and superscripts the entire cell.
That's definitely not what I was intending. Also, it doesn't find the symbol
in any of the cells that have been copied, so they're completely untouched.
Any suggestions? Or, can this even be done?


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Superscript Registered symbol

Those first two sentences could have been nicer.

Excel doesn't allow this character by character formatting in formulas or
numbers--only text.

Dave Peterson wrote:

If the cells that aren't working are formulas, then that's the way excel works.
If the cells are numeric and just show the (R) symbol because of formatting,
then that's the way excel works.

But if the cells are text and actually contain those symbols, you're going to
have to dump the "Replace All" technique and loop through the cells--and loop
through the value in the cells (if the cell has multiple (R) symbols).

This worked ok for me:

Option Explicit
Sub FancyR()

Dim RegTM As String
Dim FirstAddress As String
Dim FoundCell As Range
Dim wks As Worksheet
Dim HowMany As Long
Dim iPos As Long
Dim StartPos As Long

RegTM = Chr(174) '®

Set wks = Worksheets("sheet1")

With wks
With .Cells
Set FoundCell = .Find(what:=RegTM, after:=.Cells(.Cells.Count), _
LookIn:=xlValues, lookat:=xlPart, _
searchorder:=xlByRows, _
MatchCase:=False, searchdirection:=xlNext)

If FoundCell Is Nothing Then
MsgBox RegTM & " not found!"
Exit Sub
End If

FirstAddress = FoundCell.Address

Do
StartPos = 1
Do
iPos _
= InStr(StartPos, FoundCell.Value, RegTM, vbTextCompare)
If iPos = 0 Then
Exit Do
End If
FoundCell.Characters(Start:=iPos, Length:=1) _
.Font.Superscript = True
StartPos = iPos + 1
Loop

Set FoundCell = .FindNext(after:=FoundCell)

If FoundCell.Address = FirstAddress Then
Exit Do
End If

Loop

End With
End With
End Sub

Christopher wrote:

I'm creating acombination of worksheets that will allow me to generate a
printable report page, based on technical and non-technical information input
on a collecting worksheet. Depending on my selections/answers, information
will be copied, displayed, hidden, etc. Some of my information includes the
registered symbol, ®, but I want it to be in superscript. Originally I
formatted the character in the source cells, but only the contents are copied
by my formulas, not the formats. I tried the following macro, to no avail:

Sub FancyR()
With Application.ReplaceFormat.Font
.Superscript = True
.Subscript = False
End With
Cells.Replace What:="®", Replacement:="®", LookAt:=xlPart, SearchOrder _
:=xlByRows, MatchCase:=False, SearchFormat:=False, ReplaceFormat:=True
End Sub

This macro simply finds an instance and superscripts the entire cell.
That's definitely not what I was intending. Also, it doesn't find the symbol
in any of the cells that have been copied, so they're completely untouched.
Any suggestions? Or, can this even be done?


--

Dave Peterson


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Superscript Registered symbol

Don't worry too much about being nice. I appreciate the answer, although I
was hoping for a different one. All the text is either generated by a
formula or copied from the input page (which is a formula too, I guess), so
it looks like I'll be out of luck. I'm still going to try your code to see
if it'll help at all. Thanks.

"Dave Peterson" wrote:

Those first two sentences could have been nicer.

Excel doesn't allow this character by character formatting in formulas or
numbers--only text.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Superscript Registered symbol

If the stuff in the cells remain formulas, then yep, you're out of luck.

But if you paste special|values, then it'll work.

Christopher wrote:

Don't worry too much about being nice. I appreciate the answer, although I
was hoping for a different one. All the text is either generated by a
formula or copied from the input page (which is a formula too, I guess), so
it looks like I'll be out of luck. I'm still going to try your code to see
if it'll help at all. Thanks.

"Dave Peterson" wrote:

Those first two sentences could have been nicer.

Excel doesn't allow this character by character formatting in formulas or
numbers--only text.


--

Dave Peterson


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
Type a symbol useing shortcut keys rather the insert a symbol RJD Excel Discussion (Misc queries) 2 December 23rd 09 06:28 PM
Euro symbol displays as dollar symbol in Excel BrendaM Excel Worksheet Functions 5 April 24th 09 03:43 PM
How do I prevent (r) from changing to registered symbol? Lou Excel Discussion (Misc queries) 1 January 7th 09 11:22 PM
I need a symbol but "symbol" in the Insert menu is grayed-out. Nothappy Excel Discussion (Misc queries) 2 May 3rd 05 12:16 AM
How can I type (R) & not get the registered symbol (r in a circle) Yeller Excel Discussion (Misc queries) 6 February 18th 05 01:31 AM


All times are GMT +1. The time now is 11:59 AM.

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"