+ Reply to Thread
Results 1 to 3 of 3

User Forms Basics - Text Boxes to Named Range

  1. #1
    Registered User
    Join Date
    07-06-2009
    Location
    NH, USA
    MS-Off Ver
    2010 & 2013
    Posts
    38

    Question User Forms Basics - Text Boxes to Named Range

    So, first time with user form user (redundant much?). I got some help yesterday over in this thread: User Form Basics - Populating Text Boxes. A few tweaks later and its reading the data just fine. Some of the specific form objects and range names have changed, but it's the same logic.

    Anyway, this isn't just for display. I need to export the data back to the spreadsheet. So, I plugged this line into the event handler for the "Save & Exit" button on the sample form in the other thread:

    Please Login or Register  to view this content.
    Excel responds with...

    Run-time error '1004':
    Method 'Range' of object '_Global' failed
    If I change the code to read:

    Please Login or Register  to view this content.
    It dumps the value in the cell H5 on the current worksheet.

    As before, the named ranges are not cell references. Some are static values, some are formulas. They don't exist anywhere except the Name Manager. To make it more confusing, I've used Range with similar named ranges in quite a few other procedures, and it works just fine. Only here, where it involves a user form, do I have a problem.

    Any thoughts?
    Last edited by T.J. Lanza; 09-24-2009 at 03:36 PM. Reason: Solved! royUK is a genius.

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: User Forms Basics - Text Boxes to Named Range

    You aren't using ranges. Try this
    Please Login or Register  to view this content.
    This should over rite he name value with the textbox value
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Registered User
    Join Date
    07-06-2009
    Location
    NH, USA
    MS-Off Ver
    2010 & 2013
    Posts
    38

    Re: User Forms Basics - Text Boxes to Named Range

    Quote Originally Posted by royUK View Post
    You aren't using ranges. Try this
    Please Login or Register  to view this content.
    This should over rite he name value with the textbox value
    Absolutely brilliant. Thank you very much.

    Strange, that in some ways you can use them like they are a range, and in other ways you can't. I figured there was some way to manipulate the names directly, I just wasn't sure the syntax for it. Gotta remember to look in the "Collections" part of the VBA language reference. I'd seen mention of the Names collection, but I hadn't put two and two together.

+ 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