Range to work from a string.

Important Notice


Please note that on 14th December 2023 users will experience an expected outage whilst we make upgrades to our network. We anticipate this process may take a couple of hours and so we apologise in advance for any inconvenience.

  • I have made a function that converts column numbers to column letters, alphacol.


    I am having trouble reading the Range, rng1 after it has been set.


    There is an error: "Object does not support this property or method"
    on line: "Sheets("Graph").ChartObjects("Chart 1").Chart.SeriesCollection(k).XValues = Sheets("PlotData").rng1"


    If I change rng1 to Range(rng1) I get this error: "Application-defined or object-defined error"
    on this line: "Sheets("Graph").ChartObjects("Chart 1").Chart.SeriesCollection(k).XValues = Sheets("PlotData").Range(rng1)"


    How do I get the Range to work with the function?

  • Re: Range to work from a string.


    Rng is a variable, not a property of a sheet. When you assign a range to it, the range is specific to a sheet, so you don't need to try and qualify the variable with a sheet too. Anyway, I'd just use the address string directly


    Code
    Sheets("Graph").ChartObjects("Chart 1").Chart.SeriesCollection(k).XValues = "=PlotData!" & String1

    Rory
    Theory is when you know something, but it doesn’t work. Practice is when something works, but you don’t know why. Programmers combine theory and practice: nothing works and they don’t know why

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!