+ Reply to Thread
Results 1 to 9 of 9

Userform populated back from cells

  1. #1
    Forum Contributor
    Join Date
    05-23-2014
    Location
    Fredericia, Denmark
    MS-Off Ver
    Windows Office 2013, Excel 10
    Posts
    139

    Userform populated back from cells

    I'm using this code to populate cells in a a range from a userform:
    Please Login or Register  to view this content.
    Question: how would I adapt this code so that when the first cell in the range of cells originally populated by the userform is clicked, that the userform appears with the same content in the userform textboxes. The idea is to be able to "reuse" the form to adjust content in the cells without having to open up a new userform and edit each text box. Is there some way to do this?

    Thanks for your help! David

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

    Re: Userform populated back from cells

    All you should need to do is 'reverse' this section of code,
    Please Login or Register  to view this content.
    like this.
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  3. #3
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: Userform populated back from cells

    In order to deal with this part of your question:
    Quote Originally Posted by dgibney View Post
    when the first cell in the range of cells originally populated by the userform is clicked
    Use the below in the sheet code (right click the sheet tab and select 'view code') then enter the below there.
    Please Login or Register  to view this content.
    Obviously change the reference to A1:A40 to the range you need.

    Combined with Norie's reply you should be able to figure it all out. Use Target in place of ActiveCell.


    BSB
    Last edited by BadlySpelledBuoy; 10-20-2016 at 01:56 PM.

  4. #4
    Forum Contributor
    Join Date
    05-23-2014
    Location
    Fredericia, Denmark
    MS-Off Ver
    Windows Office 2013, Excel 10
    Posts
    139

    Re: Userform populated back from cells

    Hi Norrie, I tried replacing the original code with what you provided. I presume that's what you meant by "reverse"? Unfortunately it doesn't work. Any other thoughts? I do have this sheet code, which trigger the userform to populate the cells:
    Please Login or Register  to view this content.
    Thanks for your help. David

  5. #5
    Forum Contributor
    Join Date
    05-23-2014
    Location
    Fredericia, Denmark
    MS-Off Ver
    Windows Office 2013, Excel 10
    Posts
    139

    Re: Userform populated back from cells

    Thanks BSB, I already have this code working in the sheet:
    [CODE][/Private Sub Worksheet_SelectionChange(ByVal Target As Range)

    If Not Intersect(Target, Range("B5:B7,F5:F7, J5:J7, N5:N7, R5:R7")) Is Nothing Then

    ASSIGNMENT_FORM.Show
    End If
    End Sub

    CODE]

    But thanks for thinking of this because of course the useform wouldn't work without it! Much appreciated. David

  6. #6
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: Userform populated back from cells

    Quote Originally Posted by dgibney View Post
    Hi Norrie, I tried replacing the original code with what you provided. I presume that's what you meant by "reverse"? Unfortunately it doesn't work. Any other thoughts?
    If you could give us more of an idea of the layout of your workbook, or even better attach it to this thread, then we can help you with the code to repopulate the userform.

    BSB

  7. #7
    Forum Contributor
    Join Date
    05-23-2014
    Location
    Fredericia, Denmark
    MS-Off Ver
    Windows Office 2013, Excel 10
    Posts
    139

    Re: Userform populated back from cells

    Sorry for the late response, I was gone for a few days. I've attached the file, my attempt at making the userform info populate from the cells to the userform, and vice versa. It's not quite there.... Hopefully, it's an easy fix.

    Thanks again. David

  8. #8
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: Userform populated back from cells

    See attached for one method.

    I've added some Public string variables to a module that are used to store the details pertaining to the task you click on.
    Then I've added a UserForm initialize event that checks if these strings are empty or not. If not the the form will be populated, if empty then the form opens in the blank state you had already set up.

    Hope that helps point you in the right direction.

    BSB

  9. #9
    Forum Contributor
    Join Date
    05-23-2014
    Location
    Fredericia, Denmark
    MS-Off Ver
    Windows Office 2013, Excel 10
    Posts
    139

    Re: Userform populated back from cells

    This is perfect! Just what I needed. Thanks for your help, it 's very much appreciated.

+ 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] Counting populated controls on a UserForm
    By BanginMyHeadOnMyDesk in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-29-2015, 03:24 AM
  2. [SOLVED] Userform to search worksheet and display data back to the userform
    By zip247 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-05-2015, 05:46 AM
  3. Replies: 1
    Last Post: 03-11-2015, 07:27 AM
  4. [SOLVED] Userform with 2 comboboxes populated from database
    By nailgun80 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 02-05-2014, 03:56 AM
  5. [SOLVED] Bring back date from last populated cell in range
    By tiger01 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 11-20-2013, 06:26 AM
  6. [SOLVED] userForm loop that returns info back into cells (with some cells not included)
    By Sleepyshy in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 12-13-2012, 12:04 PM
  7. Error in populated listbox userform
    By herukuncahyono in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-30-2010, 09:54 PM

Tags for this Thread

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