Refresh/Initialize one UserForm from another?

jmpatrick

Active Member
Joined
Aug 17, 2016
Messages
477
Office Version
  1. 365
Platform
  1. Windows
I have a couple UserForms. One is used to enter and edit data (called Settings), and one that stays open at all times and is used strictly to monitor data (called SubCodeReference).

What I need to happen is have the SubCodeReference UserForm refresh or re-initialize when the macro below is run:

VBA Code:
Private Sub cmdUpdateSub_Click()
Dim SubName_id As String
SubName = Trim(SubName.Text)
LastRow = Worksheets("Subdivisions").Cells(Rows.Count, 6).End(xlUp).Row
For i = 1 To LastRow
If Worksheets("Subdivisions").Cells(i, 6).Value = SubName Then
   Worksheets("Subdivisions").Cells(i, 6).Value = EditSubName.Text
   Worksheets("Subdivisions").Cells(i, 2).Value = SubCode.Text
   Worksheets("Subdivisions").Cells(i, 3).Value = FalconCode.Text
   Worksheets("Subdivisions").Cells(i, 5).Value = SubInitials.Text
   Worksheets("Subdivisions").Cells(i, 15).Value = FloorsSelection.Text
   Worksheets("Subdivisions").Cells(i, 16).Value = EES_BW_Select.Text
   Worksheets("Subdivisions").Cells(i, 8).Value = FieldManager.Text
End If
Next

        With Me
            .SubName.Value = Null
            .EditSubName = ""
            .SubCode.Value = ""
            .SubInitials.Value = ""
            .FloorsSelection.Value = Null
            .FieldManager.Value = Null
        End With
        
        SubCodeReference.Repaint
        
        UserForm_Initialize
        
        Call cmdResetSub_Click
        Call ReplyEditSub

End Sub

I added
VBA Code:
SubCodeReference.Repaint
but it doesn't work.

Is it possible to refresh/repaint/re-initialize a UserForm from another UserForm?
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Seems like I'm inching closer! I added this:

VBA Code:
        With SubCodeReference
        .Initialize
        End With

Now, when cmdUpdateSub_Click runs, SubCodeReference flickers but the data doesn't update.

Here's the complete code:

VBA Code:
Private Sub cmdUpdateSub_Click()
Dim SubName_id As String
SubName = Trim(SubName.Text)
LastRow = Worksheets("Subdivisions").Cells(Rows.Count, 6).End(xlUp).Row
For i = 1 To LastRow
If Worksheets("Subdivisions").Cells(i, 6).Value = SubName Then
   Worksheets("Subdivisions").Cells(i, 6).Value = EditSubName.Text
   Worksheets("Subdivisions").Cells(i, 2).Value = SubCode.Text
   Worksheets("Subdivisions").Cells(i, 3).Value = FalconCode.Text
   Worksheets("Subdivisions").Cells(i, 5).Value = SubInitials.Text
   Worksheets("Subdivisions").Cells(i, 15).Value = FloorsSelection.Text
   Worksheets("Subdivisions").Cells(i, 16).Value = EES_BW_Select.Text
   Worksheets("Subdivisions").Cells(i, 8).Value = FieldManager.Text
End If
Next

        With Me
            .SubName.Value = Null
            .EditSubName = ""
            .SubCode.Value = ""
            .SubInitials.Value = ""
            .FloorsSelection.Value = Null
            .FieldManager.Value = Null
        End With
                     
        UserForm_Initialize
      
        With SubCodeReference
        .Initialize
        End With
      
        Call cmdResetSub_Click
        Call ReplyEditSub

End Sub

btw: Both UserForms are set to open Modeless.
 
Upvote 0
Still working on this one. Here's the code that populates the SubCodeReference UserForm:

VBA Code:
Private Sub UserForm_Initialize()
   
    SCR_SubCode_Name_01.Text = Sheets("Subdivisions").Range("A1")
   
End Sub

If I set a ControlSource for SCR_SubCode_Name_01 that points to Sheets("Subdivisions").Range("A1") will the SCR_SubCode_Name_01 TextBox update dynamically when the source data changes?
 
Upvote 0

Forum statistics

Threads
1,215,026
Messages
6,122,738
Members
449,094
Latest member
dsharae57

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top