Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #3  
Old 04-23-2018, 09:27 AM
NoSparks NoSparks is offline Fill userform, combobox and frame based on data from multiple worksheets Windows 7 64bit Fill userform, combobox and frame based on data from multiple worksheets Office 2010 64bit
Excel Hobbyist
 
Join Date: Nov 2013
Location: British Columbia, Canada
Posts: 842
NoSparks is a glorious beacon of lightNoSparks is a glorious beacon of lightNoSparks is a glorious beacon of lightNoSparks is a glorious beacon of lightNoSparks is a glorious beacon of light
Default

to get started... try this for your form Initialization
Code:
Private Sub UserForm_Initialize()

Dim Ws As Worksheet, lr As Long, i As Long, j As Long
Dim dic As Object, arr As Variant
Dim ctrl As Control, thisFrame As Control

Set dic = CreateObject("Scripting.Dictionary")

For Each Ws In ActiveWorkbook.Worksheets
    Select Case UCase(Ws.Name)
    Case "FY2019", "FY2020", "FY2021", "FY2022", "FY2023"
        With Ws
            lr = .Cells.Find(What:="*", SearchDirection:=xlPrevious, SearchOrder:=xlByRows).Row
            'for combo drop down
            arr = .Range("B2:B" & lr)
            For i = 1 To UBound(arr, 1)
                If arr(i, 1) <> "" And InStr(arr(i, 1), "Total") = 0 And InStr(arr(i, 1), "TOTAL") = 0 Then
                    dic(arr(i, 1)) = 1
                End If
            Next i
            'for labels
            j = 3
            Set thisFrame = Controls("frame" & Ws.Name)
            For Each ctrl In thisFrame.Controls
                If TypeOf ctrl Is MSForms.Label Then
                    ctrl.Caption = Format(.Cells(1, j).Value, "mmm-yy")
                    j = j + 1
                End If
            Next ctrl
        End With
    End Select
Next Ws
            
'populate combobox
cboFYList.List = Application.Transpose(dic.keys)

End Sub
Reply With Quote
 

Tags
combobox, frame, userform



Similar Threads
Thread Thread Starter Forum Replies Last Post
Fill userform, combobox and frame based on data from multiple worksheets Summing data from multiple worksheets in a workbook and placing into another worksheet safrac Excel 17 10-04-2022 12:21 PM
Merging 2 different cells containing IF formula & change in cell values based on multiple time frame jay_excel Excel 0 07-29-2017 11:04 PM
Excel to Word data import based on UserForm entry jhancock1994 Word VBA 8 05-16-2017 04:41 PM
Fill userform, combobox and frame based on data from multiple worksheets Using combobox to pass data from an Excel spread sheet to text boxes on userform Stewie840 Word VBA 14 12-17-2015 10:13 PM
Fill userform, combobox and frame based on data from multiple worksheets Conditional color fill based on presence of data avanderh Excel 11 07-28-2011 09:10 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:11 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft