+ Reply to Thread
Results 1 to 6 of 6

Change load sequence for dynamic loading userform

Hybrid View

  1. #1
    Forum Expert nigelog's Avatar
    Join Date
    12-14-2007
    Location
    Cork, Ireland
    MS-Off Ver
    Office 365 Windows 10
    Posts
    2,293

    Change load sequence for dynamic loading userform

    Hi

    the attached section of a workbook dynamically loads info to a userform. Now that I have had to add 4 more items of data it has become unwieldy and it would be much better if last 4 headings would load dynamically under one another as there will never be more that 8 of each maximum

    the form presently loads 8 columns so it would need to load columns 1 - 3 as per is and then column 4 loading the remaining heading label and data one after another

    The code was created by a member here and is above my abilty, I would appreciate if someone could take a look

    rgds
    Attached Files Attached Files
    Last edited by nigelog; 04-12-2017 at 04:28 AM.

  2. #2
    Forum Expert nigelog's Avatar
    Join Date
    12-14-2007
    Location
    Cork, Ireland
    MS-Off Ver
    Office 365 Windows 10
    Posts
    2,293

    Re: Change load sequence for dynamic loading userform

    by playing around with settings I have managed to place the first 4 columns in the desired place in userform. Basically the first 3 columns can be handled by the code as is but column 4 needs to first place header label followed by entries from work sheet THEN place label 5 below last entry followed by next etc to last label. Attached workbook might make things clearer. Any help appreciated.
    Private Sub CreateLabels()
    
        Dim iPitch_Column   As Integer
        Dim iEmployeeNo     As Integer
        Dim iColumnNo       As Integer
        Dim iPitch_Row      As Integer
        Dim iRowNo          As Integer
        Dim txt             As MSForms.TextBox
        Dim lbl             As MSForms.Label
    
        iPitch_Row = miCONTROL_HEIGHT + miSEPARATION
        iPitch_Column = (miWIDTH_LABEL + miSEPARATION + miWIDTH_TEXTBOX) + miSEPARATION_COLUMN
    
        For iColumnNo = miCOLUMN__SITE_1 To miCOLUMN__SITE_4
    
            iRowNo = 0
    
    '       Exclude the header row when processing Employee Data
            For iEmployeeNo = LBound(mvaEmployeeData, 1) + 1 To UBound(mvaEmployeeData, 1)
    
                If Not IsEmpty(mvaEmployeeData(iEmployeeNo, iColumnNo)) Then
    
                    iRowNo = iRowNo + 1
    
                    Set lbl = Me.Controls.Add(bstrProgID:="Forms.Label.1")
    
                    With lbl
    '''                    .BorderStyle = fmBorderStyleSingle
                        .Caption = mvaEmployeeData(iEmployeeNo, 1)
                        .Height = miCONTROL_HEIGHT
                        .Width = miWIDTH_LABEL
                        .Left = miLEFT__FIRST_COLUMN + (iPitch_Column * (iColumnNo - 2))
                        .Top = miTOP__FIRST_ROW + (iPitch_Row * (iRowNo - 1))
                    End With
    
                    Set txt = Me.Controls.Add(bstrProgID:="Forms.TextBox.1")
    
                    With txt
    
                        .TextAlign = fmTextAlignCenter
                        .Locked = True
                        .Height = miCONTROL_HEIGHT
                        .Width = miWIDTH_TEXTBOX
                        .Value = Format(mvaEmployeeData(iEmployeeNo, iColumnNo), "dd mmm yy")
                        .Left = lbl.Left + miWIDTH_LABEL + miSEPARATION
                        .Top = miTOP__FIRST_ROW + (iPitch_Row * (iRowNo - 1))
    
                        If DateValue(.Value) - Now() <= miWarningDays Then
    
                            txt.BackColor = vbRed
                        End If
    
                    End With
    
                End If
    
            Next iEmployeeNo
    
        Next iColumnNo
    'For iColumnNo = miCOLUMN__SITE_5 To miCOLUMN__SITE_8 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    End Sub
    Attached Files Attached Files
    Last edited by nigelog; 04-07-2017 at 04:14 AM.

  3. #3
    Forum Expert nigelog's Avatar
    Join Date
    12-14-2007
    Location
    Cork, Ireland
    MS-Off Ver
    Office 365 Windows 10
    Posts
    2,293

    Re: Change load sequence for dynamic loading userform

    By trial and error I can place the header labels in the column with the approximate required spacing. To load the labels and textboxes is there a way I can reference the position of the header label itself to space the data below its own label.
    Attached Files Attached Files

  4. #4
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,641

    Re: Change load sequence for dynamic loading userform

    Hi again,

    Thanks for your private message re the above.

    See if the attached version of your workbook does what you need.

    Regards,

    Greg M
    Attached Files Attached Files

  5. #5
    Forum Expert nigelog's Avatar
    Join Date
    12-14-2007
    Location
    Cork, Ireland
    MS-Off Ver
    Office 365 Windows 10
    Posts
    2,293

    Re: Change load sequence for dynamic loading userform

    Perfect, you are a gentleman Greg

    Pint for you when next in Dublin...

    Will mark as solved

  6. #6
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,641

    Re: Change load sequence for dynamic loading userform

    Hi again,

    Many thanks for your feedback and also for the Reputation increase - much appreciated!

    You're welcome - glad I was able to help.

    Best regards,

    Greg M

+ 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. Error trying to import userform into Outlook: Unable to load UserForm.FRX
    By jeffclanders in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-08-2016, 12:36 PM
  2. [SOLVED] Userform: Load on Selection Change & Populate Form
    By daffodil11 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-13-2015, 06:34 PM
  3. Replies: 3
    Last Post: 10-23-2012, 07:50 AM
  4. Pre-load listbox selections only loading 1 selection
    By skysurfer in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-15-2010, 10:22 AM
  5. Get Image dimentions before loading? if wrong dimention do not load...
    By homasa in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-04-2010, 12:16 PM
  6. Loading Excel - please help - takes ages to load
    By Smilersal in forum Excel General
    Replies: 0
    Last Post: 07-12-2006, 09:15 AM
  7. [SOLVED] Can I load a general macro without loading an excel document?
    By Neil.Wills in forum Excel General
    Replies: 1
    Last Post: 08-31-2005, 08:05 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