+ Reply to Thread
Results 1 to 7 of 7

assigning a range based on a string

  1. #1
    Valued Forum Contributor Sean Thomas's Avatar
    Join Date
    03-25-2012
    Location
    HerneBay, Kent, UK
    MS-Off Ver
    Excel 2007,2016
    Posts
    971

    assigning a range based on a string

    I'm having difficulties with this

    how do I get the Userngname range to equal the range found by Username string?

    Please Login or Register  to view this content.
    Regards
    Sean

    Please add to my reputation if you think i helped
    (click on the star below the post)
    Mark threads as "Solved" if you have your answer
    (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code:
    [code] Your code here [code]
    Please supply a workbook containing example Data:
    It makes its easier to answer your problem & saves time!

  2. #2
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: assigning a range based on a string

    In your example, Userngname appears to be the same range as UseK2WCRng?

  3. #3
    Valued Forum Contributor Sean Thomas's Avatar
    Join Date
    03-25-2012
    Location
    HerneBay, Kent, UK
    MS-Off Ver
    Excel 2007,2016
    Posts
    971

    Re: assigning a range based on a string

    Well that's what I would like it to do but it fails

    the idea was to run this procedure through a range and look up the range to use for the userngname range
    however I am getting the string via username of "UseK2WCRng", but when I try to use this to assign it to userngname range so I can use it in the countifs formula it wont work

  4. #4
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: assigning a range based on a string

    It won't work because the value of Username ("UseK2WCRng") is not a named range. You have defined it as object (range) variable. It would work if you commented out
    Please Login or Register  to view this content.

  5. #5
    Valued Forum Contributor Sean Thomas's Avatar
    Join Date
    03-25-2012
    Location
    HerneBay, Kent, UK
    MS-Off Ver
    Excel 2007,2016
    Posts
    971

    Re: assigning a range based on a string

    What I wanted to do was have a number of ranges already set as per
    Please Login or Register  to view this content.

    but then depending on what was in Sheet4.Cells(Rep.Row, "B").Value it would be able to use that particular range in my countif

  6. #6
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: assigning a range based on a string

    I think the way to do it is thus
    Please Login or Register  to view this content.

  7. #7
    Valued Forum Contributor Sean Thomas's Avatar
    Join Date
    03-25-2012
    Location
    HerneBay, Kent, UK
    MS-Off Ver
    Excel 2007,2016
    Posts
    971

    Re: assigning a range based on a string

    Cheers Stephen, I will give it a go tomorrow
    looks like it may work!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. assigning cell value based on a number range
    By dzedncnfused in forum Excel General
    Replies: 2
    Last Post: 09-11-2013, 07:07 PM
  2. Assigning value based upon number within a range. excel 2003
    By elewis1220 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 08-05-2013, 05:05 PM
  3. Assigning period and quarter based on date range. VBA
    By Lifeseeker in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-28-2011, 09:04 PM
  4. Replies: 4
    Last Post: 07-15-2011, 02:01 PM
  5. Replies: 5
    Last Post: 04-06-2010, 04:23 PM
  6. Replies: 2
    Last Post: 04-30-2009, 07:30 PM
  7. automatically assigning pivot based on unknown range?
    By AmyTaylor in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-08-2006, 04:04 AM

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