#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 229
Default format & function

How to restore superscript or subscript format of text while using functions
like concatenate etc
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default format & function

Formulas don't support this kind of character by character formatting.



yshridhar wrote:

How to restore superscript or subscript format of text while using functions
like concatenate etc


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 4,624
Default format & function

You can't - functions return values, not formatting.

You'd have to use an event macro instead. For instance, say your formula
was

F3: =A1 & " " & J1

Then you could put something like this in your worksheet code module
(right-click the worksheet tab and choose View Code):


Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Dim rCell1 As Range
Dim rCell2 As Range
Dim i As Long
Dim j As Long
If Not Intersect(Target, Range("A1,J1")) Is Nothing Then
Set rCell1 = Range("A1")
Set rCell2 = Range("J1")
With Range("F3")
.Clear
.Value = rCell1.Text & " " & rCell2.Text
For i = 1 To Len(rCell1.Text)
With .Characters(i, 1).Font
.Superscript = rCell1.Characters(i, 1).Font.Superscript
.Subscript = rCell1.Characters(i, 1).Font.Subscript
End With
Next i
For j = 1 To Len(rCell2.Text)
With .Characters(j + i, 1).Font
.Superscript = rCell2.Characters(j, 1).Font.Superscript
.Subscript = rCell2.Characters(j, 1).Font.Subscript
End With
Next j
End With
End If
End Sub





In article ,
yshridhar wrote:

How to restore superscript or subscript format of text while using functions
like concatenate etc

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 229
Default format & function

Thank you Mr. McGimpsey
Can this be extended say i would like to use this macro to concatenate
column A and column J in column F
with many thanks
Sridhar

"JE McGimpsey" wrote:

You can't - functions return values, not formatting.

You'd have to use an event macro instead. For instance, say your formula
was

F3: =A1 & " " & J1

Then you could put something like this in your worksheet code module
(right-click the worksheet tab and choose View Code):


Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Dim rCell1 As Range
Dim rCell2 As Range
Dim i As Long
Dim j As Long
If Not Intersect(Target, Range("A1,J1")) Is Nothing Then
Set rCell1 = Range("A1")
Set rCell2 = Range("J1")
With Range("F3")
.Clear
.Value = rCell1.Text & " " & rCell2.Text
For i = 1 To Len(rCell1.Text)
With .Characters(i, 1).Font
.Superscript = rCell1.Characters(i, 1).Font.Superscript
.Subscript = rCell1.Characters(i, 1).Font.Subscript
End With
Next i
For j = 1 To Len(rCell2.Text)
With .Characters(j + i, 1).Font
.Superscript = rCell2.Characters(j, 1).Font.Superscript
.Subscript = rCell2.Characters(j, 1).Font.Subscript
End With
Next j
End With
End If
End Sub





In article ,
yshridhar wrote:

How to restore superscript or subscript format of text while using functions
like concatenate etc


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
How do I format Concatenate function? deepc Excel Discussion (Misc queries) 3 April 10th 07 12:53 PM
Cannot format data after using mid() function () Excel Worksheet Functions 3 March 22nd 06 08:04 PM
Function to format cells??? 43fan Excel Worksheet Functions 2 March 2nd 05 01:45 PM
the function FORMAT() Jonas Excel Discussion (Misc queries) 1 January 28th 05 03:53 PM
Problem with function format Steve Excel Worksheet Functions 2 December 27th 04 01:43 PM


All times are GMT +1. The time now is 10:40 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"