Creating macro that loops through each cell in a used range and then calls a separate sub?

TMM1968

Board Regular
Joined
Jul 16, 2012
Messages
59
I have multiple excel files that contain superscript references in cells. I figured out a script that can ID and then convert superscript references to <sup></sup> in the cells. It works with multiple refs in a single cell as well.

Unfortunately, right now it works on one cell. I would like to create a macro that loops through each cell in a used range and then calls a separate sub?
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
The script that can ID and then convert superscript references to <sup></sup> in the cells as I referenced. It works with multiple refs in a single cell as well.
Unfortunately, right now it works on one cell. I just need a macro to loop through each cell in range to run this script when it ID's superscript reference in cell. Thanks in advance for any help.
 
Upvote 0
Its hard to tell without a copy of the code or workbook. But you can make this type of construction

Code:
Macro1

For i=1 to 24
Call Macro2
next i

end sub
 
Upvote 0
Its hard to tell without a copy of the code or workbook. But you can make this type of construction

Code:
Macro1

For i=1 to 24
Call Macro2
next i

end sub


Thanks for this. I included below the script that would go through each XLS file(there are 1400) and identify each cell that has footnote reference and do conversion in that cell. Unfortunately, right now it works on one cell only. I need a macro that loops through each cell in a used range and then calls a separate sub.

Sub characterlooper()

'Dim allmycells As Range, CheckCells As Range
'Set CheckCells = ActiveSheet.UsedRange
'For Each allmycells In CheckCells

Dim i As Long, b As Integer, sStr1 As String, sStr As String, extractChar
Dim sChr As String, var4
b = 0
sStr1 = ActiveCell.Value
var4 = sStr1
For i = 1 To Len(sStr1)
sChr = Mid(sStr1, i, 1)

Dim var3, footnote, Start, Endd, j As Integer
var3 = ActiveCell.Characters(Start:=i, length:=1).Font.Superscript

If var3 = "True" Then
j = i + b
'MsgBox "True"
'NEED TO ACCOUNT FOR COMMAS and SPACES IN multi-footnote refs. See Table 104.
footnote = "<sup>" & sChr & "</sup>"
Start = Left(var4, j - 1)
Endd = Right(var4, Len(var4) - j)
var4 = Start & footnote & Endd
b = b + 11
Else
'MsgBox "False"
End If
Next
 
Upvote 0

Forum statistics

Threads
1,214,590
Messages
6,120,421
Members
448,961
Latest member
nzskater

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