+ Reply to Thread
Results 1 to 10 of 10

Easy Duplication & Assigning of User-Forms

  1. #1
    Forum Contributor
    Join Date
    05-23-2013
    Location
    Ohio
    MS-Off Ver
    Excel 2013
    Posts
    259

    Easy Duplication & Assigning of User-Forms

    Hello Everyone,

    So I've started delving into the world of custom user-forms.

    If I take the time to customize a user-form (which I have) can I easily replicate that form and its cell references?

    Hypothetical to help explain my question:

    Say I have a user-form with 4 text boxes and two drop-downs. Each of those 6 fields corresponds to cells A1:A6. The macro to load the user-form is tied to a button sitting in cell A7. If I want multiple rows to each have a buttom that launches a user-form to populate that row's values, can I easily replicate the references and UF projects themselves?

    Do I need another macro to replicate it for me? I'm testing using UF's in a personal sheet, but I'd like to incorporate them into a spreadsheet for my company. Problem is, that sheet will need 20-30 UFs, each UF having multiple fields which will reference cells. I really don't want to manually update all those references (plus, the more I do manually, the bigger the chance I'll make a mistake somewhere that I probably won't catch before it would roll out).

    If you all need more details or more explanation, please let me know. If you could tell me if this is even possible (maybe a way to update/change all range references for everything within a UF), I'd be happy with that. Would love to learn about this before I try to do everything the long and difficult way. And if anyone has some basic macro code I could customize to this effect, I'd be eternally greatful!

    Thanks everyone!

    -LM
    Last edited by liquidmettle; 06-07-2015 at 01:28 AM.

  2. #2
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,125

    Re: Easy Duplication & Assigning of User-Forms

    Quote Originally Posted by liquidmettle View Post
    can I easily replicate that form and its cell references?
    Yes and No.

    You can use the copy command to copy the object structure, but not the references. :P

    to load the user-form is tied to a button sitting in cell A7.
    Then, what you would do, is to create one DYNAMIC userform. Upon loading the form (using the initialize event), you will determine which button was pressed. Then, knowing that, load the fields (probably with a Select case statement) with the relevant cell references.
    David
    (*) Reputation points appreciated.

  3. #3
    Registered User
    Join Date
    11-13-2006
    Posts
    87

    Re: Easy Duplication & Assigning of User-Forms

    You have now told us how you want to do what you are trying to achieve your goal.

    If you tell us what the goal is, we might know a better way. All we know now is that you are envisioning a method of Data Entry.

    Instead of many buttons, I like to use the Worksheet's BeforeDoubleClick Event to trigger things. I'll tell my guys, "Hey, I've got this wonderful way to help you fill out this sheet, just doubleclick in Column A on the row you want to work on."

    In the UserForm, the Activate Event sub can get the ActiveSheet and the ActiveCell.Row. This lets the Users switch back and forth, (with a Modeless Form,) between Excel and the Form.

    If the Users are always filling out or editing the same fields in the same limited number of Rows a TabStrip control on one Form might be the way to go. Use the Tabstrips's Value property to determine which row you're working on. I typically use the previous TabStip.Value to save that data on the Change Event, then the current value to update the controls when editing an existing record.

    TIP: Think very hard about any Control, Variable, and Range Names you might Use. I try to keep all that deal with the same Data Point named the same or very similar, ie, only the prefixes would be different. ("tbxFirstName." Range "FirstName," and "strFirstName")

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

    Re: Easy Duplication & Assigning of User-Forms

    You are using a user form, with cells A1:A6 to make an entry in A7.

    Changing the hard coded values to an argument that is passed before the UF is called should make it easy to work with A8:13 and A14, etc.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  5. #5
    Forum Contributor
    Join Date
    05-23-2013
    Location
    Ohio
    MS-Off Ver
    Excel 2013
    Posts
    259

    Re: Easy Duplication & Assigning of User-Forms

    Hey Everyone!

    Thank you for the early replies! I'll be traveling to New Orleans next week and won't be able to delve deeper into your initial replies. Based on some of your comments there appears to be a lot more for me to consider before I willy-nilly try my hand at implementing so many user-forms.

    I'll report once I've looked into all you've said, but thank you so much for replying so quickly!

  6. #6
    Forum Contributor
    Join Date
    05-23-2013
    Location
    Ohio
    MS-Off Ver
    Excel 2013
    Posts
    259

    Re: Easy Duplication & Assigning of User-Forms

    Okay, I'll address everyone but I am pretty stoked to continue the conversation with a few of you.

    The number one thing I've learned so far is that I have a lot more to learn!

    Tinbendr,

    That sounds like a pretty exceptional solution! Do you have an examples of macro code that would be applicable to determining which named shape was pressed (as a button to launch the user form). How might the range references be handled? Dimming some random letter as a variable but having it equal the row # of the top left cell the button is in?

    If you have a lead on this, I'll try to provide any more explanation of examples you require!

    SamT,

    Basically I haven't tried anything yet, I was looking to save time by seeing if anyone was aware of a simple way to duplicate a custom user-form while automatically updating its cell references (so that the copied user-form applied to the same cells but in the next row, for however many times I copied it).

    I've never used the BeforeDoubleClick event but I'd love to learn more about it if you have a resource or a few minutes to explain how it might impact a sheet with custom userforms (or in general if it has other applications). I can probably google it just as easily, so no worries if you don't have time.

    I've thought about using the tabstrip but I might avoid it for simplicity (I want the end users to have as little cause for confusion as possible).

    Great advice on naming : ).

    Mikerickson,

    I think you misinterpreted what i was going for in my earlier explanation. In my hypothetical example above (which won't resemble the final product, but was okay for the concept), I was saying the shape/button to launch the user-form would be in cell A7 with the userform having data entry points corresponding with cells A1-A6. No worries! I realize I could have explained it more clearly for sure.

    Thank you all for replying, sorry it took me so long to get back to you.

    Have a great Friday,

    -LM

  7. #7
    Forum Contributor
    Join Date
    05-23-2013
    Location
    Ohio
    MS-Off Ver
    Excel 2013
    Posts
    259

    Re: Easy Duplication & Assigning of User-Forms

    Hello again all!

    I'm experimenting (but have not reached a viable solution yet). Thought I would throw up some of the code I'm trying to see what you think.

    So the intent is, that when a button launches the user-form, Textbox1 will = range Q (row of button pressed). Or will save any information typed into the textbox to that cell.

    I know the range is wrong, but I'm not sure how to reference the column and number here. I can use the caller to find the row number the shape resides in (tested with a message box). How do I then incorporate that into a row? I'm thinking if I solve that one of the biggest hurdles will be surpassed.

    Thanks in advance for any help!

    Please Login or Register  to view this content.

  8. #8
    Forum Contributor
    Join Date
    05-23-2013
    Location
    Ohio
    MS-Off Ver
    Excel 2013
    Posts
    259

    Re: Easy Duplication & Assigning of User-Forms

    Hello All,

    Thank you for your consideration on this matter. I'm going to close this thread because I may have found my own abstract solution combining several bits of code from other sources.

    Once again thank you for your initial suggestions, some of them led me to find the right pieces of information (knowing what questions to ask is half the battle).

  9. #9
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Easy Duplication & Assigning of User-Forms

    Care to share your solution, or where you found it?
    If posting code please use code tags, see here.

  10. #10
    Forum Contributor
    Join Date
    05-23-2013
    Location
    Ohio
    MS-Off Ver
    Excel 2013
    Posts
    259

    Re: Easy Duplication & Assigning of User-Forms

    Hi Norie,

    As I've discovered after a bit more tinkering, I didn't quite find my solution just yet :p. I'm not sure if its against forum rules, but I started a new thread to address the issues I'm seeing (I felt it significantly different enough to justify a new post. I am certain a forum mod will tell me otherwise if I am in error).

    The link to that new thread is: http://www.excelforum.com/excel-prog...ml#post4104290

    I bypassed the original code I posted in this thread by using the offset method and determining a starting range. I've seen this work on another sheet but was not successful in my current code (link above) in getting it to work. Had a few other issues as well so hopefully I can address them all in one shot there.

+ 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. [SOLVED] Forms Check Box - Should be easy fix
    By lsteinbach in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-17-2012, 10:50 PM
  2. [SOLVED] User forms - choosing location of your data to be shown in your user form
    By jasonbwt in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-29-2012, 08:48 AM
  3. Assigning a macro to a forms button (help)
    By JazzBlues in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-25-2005, 12:05 AM
  4. new user with easy question? not easy for me
    By speakeztruth in forum Excel - New Users/Basics
    Replies: 5
    Last Post: 06-03-2005, 05:05 PM
  5. User Defined Functions - Help Text - Make it Easy for the User
    By Andibevan in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-17-2005, 06:06 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