[VBA] Quotation mark issue
Solved
Doudou95
Posted messages
1897
Registration date
Status
Member
Last intervention
-
toto40 -
toto40 -
```vba
Sub AttribuerFormule()
Dim ws As Worksheet
Set ws = ThisWorkbook.Sheets("NomDeVotreFeuille") ' Remplacez par le nom de votre feuille
ws.Range("A1").Formula = "=STXT(F2;CNUM(CHERCHE(""("";F2))+1;CNUM(CHERCHE("");"";F2))-CNUM(CHERCHE(""("";F2))-1)"
End Sub
```
Sub AttribuerFormule()
Dim ws As Worksheet
Set ws = ThisWorkbook.Sheets("NomDeVotreFeuille") ' Remplacez par le nom de votre feuille
ws.Range("A1").Formula = "=STXT(F2;CNUM(CHERCHE(""("";F2))+1;CNUM(CHERCHE("");"";F2))-CNUM(CHERCHE(""("";F2))-1)"
End Sub
```
4 answers
-
Hello Doudou,
in VBA, it looks like this:ActiveCell.FormulaR1C1 = _ "=MID(R2C6,VALUE(SEARCH(""("",R2C6))+1,VALUE(SEARCH("")"",R2C6))-VALUE(SEARCH(""("",R2C6))-1)"
The quotes become double quotes.
To ensure you get the syntax of an Excel formula in VBA, use the macro generator:
1- Write your formula correctly in Excel
2 - Tool/Macros/New Macro (this starts the recording)
3 - Select the cell containing the formula, F2 then Enter.
4 - Stop the recording.
In the macro created, you can view the correct syntax of your formula.
I. -
Thank you very much Ivan-hoe!
Even today, your message is helpful.
Nicox100 -
Thank you very much, my tutor showed me and I have the same thing, but thanks for your help :)
-