3

I have this VBA Script and I don't know how to make dynamic the bold section, so that the formula would be =StripAccent(C2), =StripAccent(C3) and so on for each i.

For i = 2 To 10  
    Cells(i, 5) = "=StripAccent(Ci)"
Next i

I read about double quotes, but it didn't work there.

3 Answers 3

3

This is a possible solution:

Public Sub TestMe()
    Dim i    As Long
    For i = 2 To 10
        Cells(i, 5) = "=StripAccent(C" & i & ")"
    Next i
End Sub

Another one is to use Cells(i,3).

Edit: If you are using a custom function from here - Converting Special Characters into alphabet then something like this can work as well (but not as a formula):

Public Sub TestMe()
    Dim i    As Long
    For i = 2 To 10
        Cells(i, 5) = StripAccent(Cells(i,3))
    Next i
End Sub
Sign up to request clarification or add additional context in comments.

Comments

2

In your case, you don't need a loop, you can directly add the Formula to your entire range, like this:

Range(Cells(2, 5), Cells(10, 5)).Formula = "=StripAccent(C2)"

Or, even "cleaner" :

Range("E2:E10").Formula = "=StripAccent(C2)"

2 Comments

@Vityata where did he mention he needs a loop? I think he wants the fomrula dragged according to the row number in column "E"
Seems legit in a way.
1
For i = 2 To 10  
    Cells(i, 5).Formula = "=StripAccent(C" & i & ")"
Next i

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.