+ Reply to Thread
Results 1 to 5 of 5

Passing value of named range ... not working? should be simple no?

  1. #1
    Registered User
    Join Date
    08-08-2010
    Location
    Ottawa, Canada
    MS-Off Ver
    Excel 2010
    Posts
    85

    Question Passing value of named range ... not working? should be simple no?

    Hi

    This is driving me nuts. I have a spreadsheet with input values on one sheet. Depending on the value chosen, it will hide/unhide rows on another sheet.

    To be "more efficient" I have tried to name ranges in Excel for the cells that hold the input values (because I use this as a template and if I need to change things slightly I don't have to go back into the code to try and find all the references for the input values... so it was supposed to save time... )

    But for whatever reason, I can't seem to get the code to even pass the value... tried setting it as Dim i as Range, or Dim i as Interger and neither worked.

    I'm sure it's something very small I'm doing wrong.

    Original Code (stating exact cell address) - works fine, I just want to change the "Cells(14,3)" for example to the named cell "Life"... Cells(17, 3) is "LTD".....
    Please Login or Register  to view this content.
    I get Object Variable or With Block variable not set if I just change to
    Please Login or Register  to view this content.
    I've tried searching internet etc, can't find similar code... any simple ideas?

  2. #2
    Forum Contributor
    Join Date
    05-25-2012
    Location
    California
    MS-Off Ver
    Excel 2010
    Posts
    194

    Re: Passing value of named range ... not working? should be simple no?

    Hi trillium,

    The problem here is the range you are referring to is not be a single cell - e.g. based on your feedback, "Life" appears to be more than 1 cell - Thus trying to return the value of multiple cells to a single variable gives you an error. If you want to select multiple cells and refer to a single value, they all must be merged together.

  3. #3
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Passing value of named range ... not working? should be simple no?

    If you select Sheet1!C14, does it say Life in the names box (left of the formula bar)?
    Entia non sunt multiplicanda sine necessitate

  4. #4
    Registered User
    Join Date
    08-08-2010
    Location
    Ottawa, Canada
    MS-Off Ver
    Excel 2010
    Posts
    85

    Re: Passing value of named range ... not working? should be simple no?

    Hi there, just lost my response!

    Yes when I select C14 is shows Life in the name range box... and it is "supposed" to be just assinged to 1 cell.. ? I will double check in the name manager to be sure it didn't select >1 cell. Thanks for all your suggestions!

  5. #5
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,516

    Re: Passing value of named range ... not working? should be simple no?

    Don't know if this is related but, in your loop, you refer to Life rather than iLife.

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


+ 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