Results 1 to 1 of 1

How do I source and initialize data from multiple sheets with one VBA code?

Threaded View

  1. #1
    Registered User
    Join Date
    09-08-2014
    Location
    NC, USA
    MS-Off Ver
    2010
    Posts
    1

    How do I source and initialize data from multiple sheets with one VBA code?

    Hello, I am new to VBA and found this code online and modified it to fit my purpose. However, I have a multipage useform and would like to be able to load data from different source worksheets into the userform. Each page has differently labelled combo/text boxes e.g. Page 1 would borrow data from sheet3 and place it into Ctrl1 and text2 etc, while Page 2 would borrow data from sheet1 and place it into CtrlX1 and textX2.

    Code:
    Private Sub UserForm_Initialize()
        ws = Sheet3.Cells(7, 1).CurrentRegion
        For j = 3 To UBound(ws)
            If InStr(c01 & ",", "," & ws(j, 1) & ",") = 0 Then c01 = c01 & "," & ws(j, 1)
        Next
        
        Ctrl1.List = Split(Mid(c01, 2), ",")
        
    End Sub
    
    Function f_list(x)
        For j = 3 To UBound(ws)
            For jj = 1 To x
                If ws(j, jj) <> Me("Ctrl1").Value Then Exit For
            Next
            If jj = x + 1 And InStr(c01 & ",", "," & ws(j, jj) & ",") = 0 Then c01 = c01 & "," & ws(j, jj)
        Next
        
        f_list = Mid(c01, 2)
    End Function
    
    Private Sub Ctrl1_Change()
        If Ctrl1.ListIndex = -1 Then Exit Sub
        
        c01 = Ctrl1.Value
        For j = 3 To UBound(ws)
            If ws(j, 1) = c01 Then Exit For
        Next
        
        For jj = 2 To 43
        Me("text" & jj).Value = ws(j, jj)
        Next
    End Sub

    I would like to source data from sheets 1, 2, 3 and so on and load it onto comboboxes/text boxes on the multipage userform.

    I desperately need your help.
    Last edited by JBeaucaire; 10-28-2014 at 06:36 PM. Reason: Added missing CODE tags. Please read and follow the Forum Rules, link above in the menu bar. Thanks.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 6
    Last Post: 02-08-2014, 05:01 AM
  2. [SOLVED] Data Validation - replace choices for multiple sheets of source data
    By mshaw1970 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-20-2013, 07:34 AM
  3. Update Data in Multiple Sheets From 1 Source Sheet
    By smfismfi in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-11-2012, 04:17 PM
  4. need help with code to copy data from multiple sheets to one sheet
    By daillest319 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-17-2012, 01:07 PM
  5. Filter copy and paste from one data source into multiple sheets
    By MrDean in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-05-2010, 01:35 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