[VBA] Quotation mark issue

Solved
Doudou95 Posted messages 1897 Registration date   Status Member Last intervention   -  
 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
```

4 answers

  1. Ivan-hoe Posted messages 433 Registration date   Status Member Last intervention   310
     
    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.
    10
  2. nicox100 Posted messages 22 Status Member 1
     
    Thank you very much Ivan-hoe!
    Even today, your message is helpful.
    Nicox100
    1
  3. Doudou95 Posted messages 1897 Registration date   Status Member Last intervention   275
     
    Thank you very much, my tutor showed me and I have the same thing, but thanks for your help :)
    0