+ Reply to Thread
Results 1 to 5 of 5

changing cell address to row/column address

  1. #1
    Registered User
    Join Date
    04-27-2010
    Location
    Pittsburgh, PA
    MS-Off Ver
    Excel 2003
    Posts
    16

    changing cell address to row/column address

    Is there a simple way to change a cell address, i.e. a2 to a row/column value, i.e. r2c1 using vba code?

    I'm trying to automate a plot scheme and the input for the xvalues and yvalues is based on row/column nomenclature versus address nomenclature..

    Example for grabbing b1:b10, the code must look like this (I think):

    ActiveChart.SeriesCollection(5).XValue = "=Sheet1!r1c2:r10c2"

    whereas, I would love to be able to put this:

    ActiveChart.SeriesCollection(5).XValue = "=Sheet1!$b$1:$b$10" - THIS FAILS

    Best regards,

    Mike

  2. #2
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: changing cell address to row/column address

    Hi michaelbails
    what do you mean by fails . what is the error message?
    If the solution helped please donate to RSPCA

    Site worth visiting: Rabbitohs

  3. #3
    Registered User
    Join Date
    04-27-2010
    Location
    Pittsburgh, PA
    MS-Off Ver
    Excel 2003
    Posts
    16

    Re: changing cell address to row/column address

    Hi Pike,


    I actually got it to work. For some reason if I put the cell index - i.e. $b$1:$b$12 as the SeriesCollection.XValue, it wouldn't work. So, I made a fix that is somewhat tedious, but it works.

    xr1 = ActiveCell.Row
    xc1 = ActiveCell.Column
    x1 = "r" & xr1 & "c" & xc1
    Selection.End(xlDown).Select
    xr2 = ActiveCell.Row
    xc2 = ActiveCell.Column
    x2 = "r" & xr2 & "c" & xc2
    ActiveCell.Offset(0, 1).Select
    yr2 = ActiveCell.Row
    yc2 = ActiveCell.Column
    y2 = "r" & yr2 & "c" & yc2
    Selection.End(xlUp).Select
    yr1 = ActiveCell.Row
    yc1 = ActiveCell.Column
    y1 = "r" & yr1 & "c" & yc1

    Sheets("Graphical Results").Select
    With ActiveChart.SeriesCollection.NewSeries
    .Name = ln
    .Values = "=" & pr & y1 & ":" & y2
    .XValues = "=" & pr & x1 & ":" & x2
    End With
    ActiveChart.SeriesCollection(5).Select
    With Selection.Border
    .Weight = xlThin
    .LineStyle = xlNone
    End With
    With Selection
    .MarkerBackgroundColorIndex = xlNone
    .MarkerForegroundColorIndex = xlAutomatic
    .MarkerStyle = xlAutomatic
    .Smooth = True
    .MarkerSize = 5
    .Shadow = False
    End With

    pr is the sheet where the data is located.

    Thanks,

    Mike

  4. #4
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326

    Re: changing cell address to row/column address

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here

  5. #5
    Registered User
    Join Date
    04-27-2010
    Location
    Pittsburgh, PA
    MS-Off Ver
    Excel 2003
    Posts
    16

    Re: changing cell address to row/column address

    I apologize for this... I am an new member. I've reposted in the correct format.

    Best,

    Mike


    I actually got it to work. For some reason if I put the cell index - i.e. $b$1:$b$12 as the SeriesCollection.XValue, it wouldn't work. So, I made a fix that is somewhat tedious, but it works.
    Please Login or Register  to view this content.
    pr is the sheet where the data is located.

    Thanks,

    Mike
    Edit/Delete Message


    Quote Originally Posted by arthurbr View Post
    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here

+ 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