Results 1 to 28 of 28

VBA code to import pick'em picks into master sheet

Threaded View

  1. #21
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: VBA code to import pick'em picks into master sheet

    Hi Chad

    The following Code is in the attached Code Book v2.xlsm along with a UserForm. The UserForm will ask you to Select a Week to Process. I'm attaching six files (five attached to this Post...the sixth will be attached to a follow-up post)

    They should be placed like this Directory Tree

    Folder H:\Desktop\CFB Pickem\ <------ Call this whatever you like...put it wherever you like
    Code Book v2.xlsm
    Target Files\
    picks master.xlsx
    Wk 1 Picks\
    Games - Week1 - Harry Cary.xlsx
    Games - Week1 - Joe Johnson.xlsx
    Games - Week1 - Mary Mary.xlsx
    Games - Week1 - Pete Smith.xlsx
    Run the Code from the Button in Code Book v2.xlsm. Let me know of issues.
    Public sWB As Workbook, tWB As Workbook
    Public sWS As Worksheet, tWS As Worksheet
    Public LR As Long
    Public Rng As Range, cel As Range
    Public myPath As String, myFile As String, PickName As String
    
    Option Explicit
    
    Sub Open_Master_File()
        Application.ScreenUpdating = False
    
        myPath = ThisWorkbook.Path & "\Target Files\"
        Application.Workbooks.Open (myPath & "picks master.xlsx")
        Set tWB = ActiveWorkbook
    
        UserForm1.Show
    
        If IsNull(UserForm1.ListBox1.Value) Then
            ActiveWorkbook.Close False
            Exit Sub
        End If
    
        Set tWS = tWB.Sheets(UserForm1.ListBox1.Value)
        tWS.Activate
        Call Open_Weekly_File
    End Sub
    
    
    Sub Open_Weekly_File()
    
        myPath = ThisWorkbook.Path & "\" & UserForm1.ListBox1.Value & " Picks" & "\"
        myFile = Dir(myPath)
    
        Do While myFile <> ""
            If myFile Like "*.xlsx" Then
                Workbooks.Open myPath & myFile
                Set sWB = ActiveWorkbook
                Set sWS = sWB.Sheets(1)
                PickName = sWS.Range("C5").Value
                Call Fill_Master
                ActiveWorkbook.Close False
            End If
            myFile = Dir
        Loop
    End Sub
    
    
    Sub Fill_Master()
        Dim myName As Range
    
        With tWS
            LR = .Cells(3, 1).End(xlDown).Offset(0, 0).Row
            Set Rng = .Range("A3:A" & LR)
            Set myName = Rng.Find(PickName, , xlValues, xlWhole, xlByRows, xlNext, False)
            If Not myName Is Nothing Then
                myName.Offset(0, 1).Resize(1, 14).Value = sWS.Range("AA2:AN2").Value
                myName.Offset(0, 17).Value = sWS.Range("AO2").Value
                myName.Offset(0, 19).Value = sWS.Range("AP2").Value
            End If
        End With
    End Sub
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Formula in one cell that picks up another based on dates provided in the same sheet
    By s.tara91 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-16-2013, 12:58 AM
  2. vba code for master sheet
    By kandre in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 06-21-2013, 10:17 AM
  3. VBA Sheet array code not working with drop down lists in master sheet
    By chiplaidlaw in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-03-2012, 11:01 AM
  4. Replies: 2
    Last Post: 07-17-2008, 08:37 AM
  5. Validation Pick Lists: Picks containing spaces
    By ComcoDG in forum Excel General
    Replies: 11
    Last Post: 07-15-2008, 04:42 PM

Tags for this Thread

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