Writing Indexes in VBA

I have a line:
Range("T4").Value = "Rule 13s voilation"

I want to write 13sas 1 3 s
i 3and sare the index 1.

Please suggest how to do this in

+5
source share
3 answers

Try the following:

Range("T4").Value = "Rule 13s voilation"
Range("T4").Characters(Start:=7, Length:=2).Font.Subscript = True

I'm not sure how this will work for you with dynamic string length.

+9
source

Try to do this manually while recording a macro, and then look at the resulting code. This will give you an answer.

Here's the cleared answer:

With Range("T4")
    .Value = "Rule 13s voilation" ' (sic)
    .Characters(Start:=7, Length:=2).Font.Subscript = True
End With
+7
source

I use this function to combine 2 cells into one. the first is text, the second is a series of links to comments

Sub setRefWithRemark()


Dim aCellRef, aCellRem, aCelTarget As Range
Dim aRow As Range

For Each aRow In Range("rgtensileRefWithRemark").Rows
    Set aCellRef = aRow.Cells(1, 1)
    Set aCellRem = aRow.Cells(1, 12)
    Set aCellTarget = aRow.Cells(1, 17)
    If aCellRef.Text <> "" Then
        With aCellTarget
           .value = aCellRef.Text & cTextSeparator & aCellRem.Text ' (sic)
           .Characters(Start:=Len(aCellRef.Text) + 2, Length:=Len(aCellRem.Text)).Font.Superscript = True
        End With
    End If
    Next
End Sub
+1
source

All Articles