Repalce with Superscript

L

Legacy 116183

Guest
I hope this is simple because I am.

I wish to replace a column of the phrase Lanc with the phrase Lancs where the final s is supeerscript.

I understand that I must use a macro to do this as Excel won't do it, but as I have never done one before ever, can someone please tell me what to do ?

Thanks
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Note you can do it manually by hightlighting just the "s" in the formula bar, then
Format ... Cells .. ticking 'superscript'

If you still need VBA:

1) is Lanc the only text in the cells, or can it be part of a larger string?
2) is Lanc only in some cells of the column?

Cheers

Dave
 
Upvote 0
Thanks for the reply, I know that I can do it via the formula bar but there are 300 entries in the column.

There columns all begin Lanc then a space then various other letters which are different in each column

Thanks
 
Upvote 0
You could try this for Column A - change the "A" references in this line for a different column
Set rng1 = Range([a1], Cells(Rows.Count, "A").End(xlUp))

Normally I'd use an array for a read write, but this needs a cell loop to handle the formatting entry

Cheers

Dave

Code:
Sub Macro1()
    Dim rng1
    Dim c
    Set rng1 = Range([A1], Cells(Rows.Count, "A").End(xlUp))
    For Each c In rng1.Cells
        If Left$(c.Value, 5) = "Lanc " Then
            c.Value = "Lancs " & Right$(c.Value, Len(c.Value) - 5)
            c.Characters(Start:=5, Length:=1).Font.Superscript = True
        End If
    Next c
End Sub
 
Upvote 0

Forum statistics

Threads
1,203,125
Messages
6,053,657
Members
444,676
Latest member
locapoca

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top