Remove Quotes String
Solved
Rob
-
yg_be Posted messages 23437 Registration date Status Contributor Last intervention -
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.
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
-
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 -
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 -
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 likeActiveChart.FullSeriesCollection(1).XValues = Weekly_Data.Range(IndicePreColon & RowX & ":" & IndiceDerColon & "26")
When I was little, the Dead Sea was only sick.
George Burns-
Otherwise, take a look here, https://lite.qwant.com/?q=vba+set+series+ton+chart+by+code&client=opensearch
I skimmed through it quickly, it seems there are resolved topics and thus some inspiration for you.
-
-
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