+ Reply to Thread
Results 1 to 6 of 6

Convert string to range

  1. #1
    Registered User
    Join Date
    12-17-2010
    Location
    Stockholm
    MS-Off Ver
    Excel 2007
    Posts
    8

    Convert string to range

    Hi all!
    I'm am very new to vba programming and have limited knowledge of excel, which is not a good combination.. =) Anyway, i'm trying to make a chart using a selection of cells. I loop the sheet and add each cell address i want (i'm looking for cells containing a specific word, then grabbing the address of the adjacent cell that contains a number). So i have a string (tmpFull) that looks like this, only longer. Each of these cells contain a number.

    $B$12,$B$13,$B$14,$B$15,$B$16,$B$17,$B$18,$B$19,$B$21,$B$22,$B$27

    I then need to assign this to my chart, so i "convert" the string to a range, or at least i'm trying to, using

    Please Login or Register  to view this content.
    And then add it to my chart (FullDatesRng made the same way)

    Please Login or Register  to view this content.
    But no matter what i do, i end up with a 1004 error. I have tried building the string with different formats like B10,B11 or "B10,B11" and so on in different combinations but nothing works. Hoping for a pointer to what i'm doing wrong here.

    Cheers!
    Last edited by DonkeyOte; 12-17-2010 at 09:11 AM.

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Convert string to range

    mavve2004, welcome to the board please be sure to use CODE tags when posting VBA.
    For more information about these and other tags, found here

    It's also generally a good idea to post a meaningful location in your profile as there can be / are significant functional differences based on locale (delimiters, dates etc...)

  3. #3
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Convert string to range

    Skip your first bit and then use:
    Please Login or Register  to view this content.
    Remember what the dormouse said
    Feed your head

  4. #4
    Registered User
    Join Date
    12-17-2010
    Location
    Stockholm
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Convert string to range

    Thanks, i have already tried that, same problem.

  5. #5
    Registered User
    Join Date
    12-17-2010
    Location
    Stockholm
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Convert string to range

    Any more suggestion on this? Thanks!

  6. #6
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Convert string to range

    The data range and series for a chart need to be rectangular ranges. No discontinous ranges are allowed.

    You could put formulas like =B12 in a separate part of the worksheet in a rectangular range and use that as the source for the chart.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

+ 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