+ Reply to Thread
Results 1 to 7 of 7

Updating a Userform Real Time

Hybrid View

TheScott Updating a Userform Real Time 05-05-2015, 01:41 PM
mehmetcik Re: Updating a Userform Real... 05-05-2015, 02:16 PM
TheScott Re: Updating a Userform Real... 05-06-2015, 02:14 AM
mehmetcik Re: Updating a Userform Real... 05-06-2015, 08:50 AM
mehmetcik Re: Updating a Userform Real... 05-06-2015, 08:52 AM
TheScott Re: Updating a Userform Real... 05-06-2015, 10:14 AM
mehmetcik Re: Updating a Userform Real... 05-06-2015, 12:08 PM
  1. #1
    Forum Contributor
    Join Date
    04-23-2014
    Location
    Liverpool...ish
    MS-Off Ver
    Excel 2013
    Posts
    126

    Updating a Userform Real Time

    What I am trying to discover is how to load a userform with worksheet data, update the worksheet via the userform and then have the new updated information show up in the userform for the user to see. The updating of the userform is the problem

    Attached is an example of what I am doing.

    Example AddSub RealTime Update.xlsm

    As Always Thanks and Regards

    Scott

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Updating a Userform Real Time

    You should load your Userform Like This:

    Private Sub UserForm_Initialize()
    
    Myarray = Range("A6:D8").Value
    Myarray2 = Range("C1:C3").Value
    
    For Count = 1 To 3
    Me.Controls("Textbox" & Count).Value = Myarray(Count, 4)
    Me.Controls("Label" & Count).Caption = Myarray(Count, 1)
    Me.Controls("Label" & Count + 10).Caption = Myarray2(Count, 1)
    Next
    
    End Sub
    Saving It Should be the reverse more or less. Bear with me.

    You will Need a command button on the userform.

    
    Private Sub CommandButton1_Click()
    
    For Count = 1 To 3
    MyArray(Count, 4) = Me.Controls("Textbox" & Count).Value + Me.Controls("Textbox" & Count + 3).Value - Me.Controls("Textbox" & Count + 6).Value
    Me.Controls("Textbox" & Count + 3).Value = ""
    Me.Controls("Textbox" & Count + 6).Value = ""
    Next
    
    Range("A6:D8").Value = MyArray
    End Sub
    This may seem like a round about method but it is fast because there is only Three read / write operations to excel involved.
    Last edited by mehmetcik; 05-05-2015 at 03:13 PM.
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  3. #3
    Forum Contributor
    Join Date
    04-23-2014
    Location
    Liverpool...ish
    MS-Off Ver
    Excel 2013
    Posts
    126

    Re: Updating a Userform Real Time

    Thank you for your response. I did as you suggested and changed the initialize sub to the arrays that you created. It appears to work well. Understanding what you did is a bit of a problem however. It would seem that arrays are going to be a particular nemesis of mine. I understand them… I can visualize them (at least to three dimensions) but for the life of me, I cannot determine when to use them nor do I seem to grasp the syntax. This could be a learning step forward but I request that you talk slowly and treat me like a child.

    As for the second part; I created the command button and added your code.

    I get a ‘sub or function not defined’ message and a halt on this line.
    myarray(Count, 4) = Me.Controls("Textbox" & Count).Value + Me.Controls("Textbox" & Count + 3).Value - Me.Controls("Textbox" & Count + 6).Value
    It struck me that ‘myarray’ should be defined at the top of the sub but I am not entirely certain how.
    I added the line from the initialize sub:

    myarray = Range("A6:D8").Value
    And got a message of runtime error 13 – type mismatch
    Debug halts on the line given above.

    myarray(Count, 4) = Me.Controls("Textbox" & Count).Value + Me.Controls("Textbox" & Count + 3).Value - Me.Controls("Textbox" & Count + 6).Value

    Regards
    Scott

  4. #4
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Updating a Userform Real Time

    try dim myarray as variant

    then

    Myarray = Range("A6:D8").Value
    should still work.

    For large Userforms Arrays are a godsend.

  5. #5
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Updating a Userform Real Time

    try dim myarray as variant

    then

    Myarray = Range("A6:D8").Value
    should still work.

    For large Userforms Arrays are a godsend.

    Did you renamecyour textboxes?

  6. #6
    Forum Contributor
    Join Date
    04-23-2014
    Location
    Liverpool...ish
    MS-Off Ver
    Excel 2013
    Posts
    126

    Re: Updating a Userform Real Time

    I must be missing something... and no doubt am. If you say it should work I take your word for it.

    I started fresh using a copy of the worksheet I uploaded to this site... the copy you would have seen
    Commented out my original code in the initalize and added yours copy and paste.
    Addee a command button leaving its name default

    Results are as I indicated previously
    this time I added the Dim statement and code as you indicated ( I think I put it in the right place ) and the results are the same


    Capture.PNG

    Regards

    Scott

  7. #7
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Updating a Userform Real Time

    I just Tried this:-

    
    Sub Macro1()
    
    
    Dim MyArray As Variant
    
    For Count = 1 To 12
    Cells(Count, 1).Value = Count * 2
    Next
    
    MyArray = Range("A1:A12").Value
    
    Range("B1:B12").Value = MyArray
    End Sub
    It worked with no issues.

+ 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. Updating separate worksheets in real-time (or close to it)
    By khemistry1911 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 01-13-2015, 12:54 PM
  2. Graphing/storing a cell that is updating in real time
    By omadA in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-18-2012, 02:51 PM
  3. Real Time Data Updating?
    By papermoon in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 06-26-2012, 07:15 PM
  4. macros not updating in real time on LAN
    By nigelog in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-14-2007, 12:27 PM
  5. Excel Forms: Updating data real-time
    By spacely in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 09-25-2007, 05:11 PM

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