+ Reply to Thread
Results 1 to 5 of 5

Reffering to a cell with variable

Hybrid View

  1. #1
    Registered User
    Join Date
    03-04-2010
    Location
    Tryshsta
    MS-Off Ver
    Excel 2003
    Posts
    7

    Reffering to a cell with variable

    Hi guys,

    Bear with me - im a complete noob when it comes to vba...i need to to a lot of graphs and i need to do it with a Do until loop.

    The expression is:

    ActiveChart.SeriesCollection(3).Values = "='Excel Tab 1'!R181C2:R181C13"

    and I need to replace the cell reference with a variable like:

    variable = 181
    ActiveChart.SeriesCollection(3).Values = "='Excel Tab 1'!R - variable - C2:R181C13"
    variable = variable + 1

    What is the correct syntax for that?? I have tried " and :...no luck..

    Thanx // JS

  2. #2
    Valued Forum Contributor rwgrietveld's Avatar
    Join Date
    09-02-2008
    Location
    Netherlands
    MS-Off Ver
    XL 2007 / XL 2010
    Posts
    1,671

    Re: Reffering to a cell with variable

    ActiveChart.SeriesCollection(3).Values = "='Excel Tab 1'!R " & variable & " C2:R181C13"
    Dont you want the Collection(3) to be Collection(variable) as well ??

    Otherwise only the last in the Loop will set the Values
    Looking for great solutions but hate waiting?
    Seach this Forum through Google

    www.Google.com
    (e.g. +multiple +IF site:excelforum.com/excel-general/ )

    www.Google.com
    (e.g. +fill +combobox site:excelforum.com/excel-programming/ )

    Ave,
    Ricardo

  3. #3
    Registered User
    Join Date
    03-04-2010
    Location
    Tryshsta
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Reffering to a cell with variable

    Thank you so much...it works...

    Is it possible to name the chart with a variable. For example now i name every chart manually:

    .ChartTitle.Characters.Text = "0"

    but I would rather name it .ChartTitle.Characters.Text = (Value in the cell R1C & variable & )

    Is it possible?

    //JS

  4. #4
    Registered User
    Join Date
    03-04-2010
    Location
    Tryshsta
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Reffering to a cell with variable

    .ChartTitle.Characters.Text = Cells(R & variable &C1).Value should work...but nope...(as I mentioned before...im a noob...)

  5. #5
    Valued Forum Contributor rwgrietveld's Avatar
    Join Date
    09-02-2008
    Location
    Netherlands
    MS-Off Ver
    XL 2007 / XL 2010
    Posts
    1,671

    Re: Reffering to a cell with variable

    Cells do not take R & C. It's Cells(Row,Column), so in your case

    Cells(variable,1).value
    AND start using CODE tags fom now on !! the # in the advanced editor.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1