Remove Quotes String

Solved
Rob -  
yg_be Posted messages 23437 Registration date   Status Contributor Last intervention   -
Hello,

I would like to update the data list of a chart.
I have a variable IndicePreColon (="AA"), and I want my code:
ActiveChart.FullSeriesCollection(1).XValues = "=Weekly_Data! $IndicePreColon$26:$AH$26" to read only AA and not "AA".

I already tried with IndicePreColon = Replace(IndicePreColon, Chr(160), ""), but without success.

Thank you in advance for your help.

4 answers

  1. Anonymous user
     
    Hello

    IndicePreColon = Replace(IndicePreColon, Chr(160), "")
    cannot work because the quotes are not part of the string value.
    They are only used to delimit the value so that you can read the code easily, but also so that the compiler knows when the string starts and when it ends.

    For a number, it's easy,
    nombre = 123.45
    here for example, it starts at the space and ends at the line break, but a string can contain spaces and line breaks. Therefore, it was necessary to normalize a delimiting character.

    Your problem is that we do not construct a range this way in VBA.
    https://forums.commentcamarche.net/forum/affich-17227322-vba-range-avec-references-variables

    --
    When I was little, the Dead Sea was just sick.
    George Burns
    0
  2. Rob
     
    Hello Whismeril,

    Thank you very much for your feedback, I can clearly see the mistake.
    So I have another question to be completely unblocked,

    How can I integrate this Range into ActivateChart?

    ActiveChart.FullSeriesCollection(1).XValues = "=Weekly_Data! Range(IndicePreColon & RowX & ":" & IndiceDerColon & "26")"

    Doesn't work,

    Thank you in advance,

    Rob
    0
    1. jordane45 Posted messages 30426 Registration date   Status Moderator Last intervention   4 830
       
      ActiveChart.FullSeriesCollection(1).XValues = "=Weekly_Data!$IndicePreColon$26:$AH$26" ActiveChart.FullSeriesCollection(1).XValues = "=Weekly_Data!" & IndicePreColon & "26:AH26" 
      0
  3. Anonymous user
     
    I don't code well enough in VBA to answer you off the top of my head, and I don't have Office on hand to try.

    That said, for me, the name of the sheet is part of the range.
    If I believe this discussion https://www.developpez.net/forums/d1154751/logiciels/microsoft-office/excel/macros-vba-excel/vba-utiliser-nom-feuille-variable/

    You should be able to write something like
    ActiveChart.FullSeriesCollection(1).XValues = Weekly_Data.Range(IndicePreColon & RowX & ":" & IndiceDerColon & "26")


    When I was little, the Dead Sea was only sick.
    George Burns
    0
  4. Rob
     
    I'm glad this helps me a lot!

    Can you tell me why this doesn't work:

    Set ListeX = Sheets("Weekly_Data").Range(Cells(26, DebutColonY), Cells(26, DerColonY)).Select

    and then I will have
    ActiveChart.FullSeriesCollection(1).XValues = ListeX
    0
    1. yg_be Posted messages 23437 Registration date   Status Contributor Last intervention   1 588
       
      Hello, you show a code, you write that it does not work, without explaining to us either what you observe (error message?), or, especially, what you wish to achieve.
      0
    2. yg_be Posted messages 23437 Registration date   Status Contributor Last intervention   1 588
       
      Using select is almost always a bad practice.
      0