+ Reply to Thread
Results 1 to 7 of 7

Make checklist from closed WB's and then save updated C'List data back to source WB

Hybrid View

Lungfish Make checklist from closed... 06-01-2011, 08:18 AM
Lungfish SOLVED : Make checklist from... 07-05-2011, 06:51 AM
Lungfish SOLVED : Make checklist from... 07-08-2011, 05:16 AM
Lungfish SOLVED : Make checklist from... 07-16-2011, 04:53 AM
Lungfish Re: Make checklist from... 07-16-2011, 04:54 AM
  1. #1
    Registered User
    Join Date
    09-18-2008
    Location
    Australia
    MS-Off Ver
    2010
    Posts
    66

    Make checklist from closed WB's and then save updated C'List data back to source WB

    Hi all, I am trying to learn VBA (mostly through examples on forum searches & VBA for dummies) and I think my head is about to explode!

    I have tried many examples of similar questions/problems with modifications but I can't seem to get anything to do anything!

    I am hoping someone can help me with what is probably a reasonably simple solution.

    I am using Excel 2010.

    I have a "Job Checklist" where all my job data is stored. Job #, Address, Details etc, and Scheduled completion date.

    There are many job checklist work books (and growing in number) stored in a single folder and I want to create a "To-Do List" workbook in the same folder that will check for upcoming jobs when it is opened or a button to "refresh" the sheet (without opening all the Job workbooks).

    The "Job Checklist" will have file names like Job Checklist 1500, Job Checklist 1550, 1600, etc.

    I would like the "To-Do List" to show me jobs that are coming up based on how many weeks to go before scheduled completion. (ie: 6 weeks to go, 5, 4, 3, 2, 1) shown in Columns C, D, E F, G based on the current days date (cellX2 Job C'List).

    There are probably 60 or 70 jobs at any one time that would be 6 weeks or sooner to scheduled completion date.

    So the To-Do List doesn't become endless I would also like to add a check box or a tick in the "complete" cell (Column H) that updates "Job C'List X" and saves updated C'List Data back to "Job C'List X" in cells in column V that corresponds to the job, so the job is marked as done and doesn't appear in the "To-Do List" again. (Maybe a button function of some sort?)

    I have attached sample work books so hopefully someone can give me some pointers on where to start.

    Regards,
    Martin
    Attached Files Attached Files
    Last edited by Lungfish; 06-01-2011 at 08:27 AM.

  2. #2
    Registered User
    Join Date
    09-18-2008
    Location
    Australia
    MS-Off Ver
    2010
    Posts
    66

    SOLVED : Make checklist from closed WB's

    Hi again, no one seemed to reply, probably because I was a complete noob and not having a proper go at the problem myself.

    I have tried several methods on this and other forums and have found that Ron De Bruins (base) code does what is needed with the necessary tweaks.
    The only thing now I can't get to work the way I want, is how the copy/paste data populates the cells in the new workbook.

    It seems to have everything to do with the line of code:

    BaseWks.Columns.AutoFit

    I have different column widths on the source Workbooks for the data. When the macro pastes the data in the new workbook, it keeps the new, blank workbook standard column widths and makes the rows massive.

    Any suggestions on what the work-around for this might be?

    Cheers,

    Martin
    Last edited by Lungfish; 07-16-2011 at 05:03 AM.

  3. #3
    Registered User
    Join Date
    09-18-2008
    Location
    Australia
    MS-Off Ver
    2010
    Posts
    66

    SOLVED : Make checklist from closed WB's

    Anybody with any suggestions?
    Last edited by Lungfish; 07-16-2011 at 05:05 AM. Reason: SOLVED

  4. #4
    Registered User
    Join Date
    09-18-2008
    Location
    Australia
    MS-Off Ver
    2010
    Posts
    66

    SOLVED : Make checklist from closed WB's

    Hi all. Couldn't sit around and wait for suggestions so I did it myself (well Sort of!)
    Firstly a big thanks to Ron De Bruin for making the foundations of this code freely available.

    To some of the "Guns" on this forum the code probably will give them a headache.
    Ron's part of the code, of course, is quite neat and efficient.
    My additions have mostly been recorded with the Macro Recorder and modified to suit from there.
    Anybody reading this and looking for answers.... The Macro Recorder can be you best friend when learning/beginning macro programming.

    Anyways, Here's what I finally came up with. Works like a charm (for what I need it to do).
    I'm gonna mark this Thread as SOLVED (by me!!!)

    (I have to paste it in parts because it's too big for 1 thread!)
    Last edited by Lungfish; 07-16-2011 at 05:06 AM. Reason: SOLVED

  5. #5
    Registered User
    Join Date
    09-18-2008
    Location
    Australia
    MS-Off Ver
    2010
    Posts
    66

    Re: Make checklist from closed WB's and then save updated C'List data back to source

    First Part of the Code:

    'A very special thanks to Ron De Bruin for making the foundations of this Macro
    'freely available.
    'http://www.rondebruin.nl/
    'This macro also requires Ron's "Basic Code Module" & his "RDB Last Module" to function.
    'These can be found on his website along with many other useful hints and tips
    
    'This Macro below will filter/search column A of the CHECKLIST WorkSheet from
    'each "JOB CHECKLIST" in the folder,
    'for a value between 0 and 5 and copy the results to a new workbook.
    'It then goes on to setup and format the new WorkSheet to suit what I need it to look like.
    
    'First we call the Function "Get_File_Names" to fill a array with all file names
    'named JOB CHECKLIST (ie. JOB CHECKLIST 1, JOB CHECKLIST 2, ETC, ETC)
    
    'If the macro finds files in the folder it then calls the macro "Get_Filter"
    
    Sub Filter_Job_Checklists()
        Dim myFiles As Variant
        Dim myCountOfFiles As Long
    
        myCountOfFiles = Get_File_Names( _
                         MyPath:="E:\Business\Crow Drainage\JOB CHECKLISTS\TEST", _
                         Subfolders:=False, _
                         ExtStr:="JOB CHECKLIST*.xlsm", _
                         myReturnedFiles:=myFiles)
    
        If myCountOfFiles = 0 Then
            MsgBox "No files that match the ExtStr in this folder"
            Exit Sub
        End If
    
        Get_Filter _
                FileNameInA:=False, _
                SourceShName:="", _
                SourceShIndex:=1, _
                FilterRng:="A1:W" & Rows.Count, _
                FilterField:=1, _
                FilterValue1:=">0", _
                FilterValue2:="<5", _
                myReturnedFiles:=myFiles
              
    End Sub

  6. #6
    Registered User
    Join Date
    09-18-2008
    Location
    Australia
    MS-Off Ver
    2010
    Posts
    66

    Re: Make checklist from closed WB's and then save updated C'List data back to source

    2nd part of the code :

    'Macro to find values (FilterValue 1 & 2) in the Job Checklists contained in the folder.
    
    Sub Get_Filter(FileNameInA As Boolean, SourceShName As String, _
                   SourceShIndex As Integer, FilterRng As String, FilterField As Integer, _
                   FilterValue1 As String, FilterValue2 As String, myReturnedFiles As Variant)
        Dim SourceRange As Range, destrange As Range
        Dim mybook As Workbook, BaseWks As Worksheet
        Dim rnum As Long, CalcMode As Long
        Dim SourceSh As Variant
        Dim rng As Range
        Dim RwCount As Long
        Dim I As Long
        Dim z As Long
        Dim vHdr As Variant
        Dim Counter As Integer
    
        'Change ScreenUpdating, Calculation and EnableEvents
        With Application
            CalcMode = .Calculation
            .Calculation = xlCalculationManual
            .ScreenUpdating = False
            .EnableEvents = False
        End With
    
        'Add a new workbook with one sheet named "FO To Do List"
        Set BaseWks = Workbooks.Add(xlWBATWorksheet).Worksheets(1)
        BaseWks.Name = "FO To Do List"
    
        'Set start row for the Data
        rnum = 2
    
        'Check if we use a named sheet or the Sheet index
        If SourceShName = "" Then
            SourceSh = SourceShIndex
        Else
            SourceSh = SourceShName
        End If
    
        'Loop through all files in the array of found files(myFiles)
        For I = LBound(myReturnedFiles) To UBound(myReturnedFiles)
            Set mybook = Nothing
            On Error Resume Next
            Set mybook = Workbooks.Open(myReturnedFiles(I))
            On Error GoTo 0
    
            If Not mybook Is Nothing Then
    
                'Set SourceRange and check if it is a valid range
                On Error Resume Next
    
                With mybook.Sheets(SourceSh)
                    Set SourceRange = Application.Intersect(.UsedRange, .Range(FilterRng))
                End With
    
                If Err.Number > 0 Then
                    Err.Clear
                    Set SourceRange = Nothing
                Else
                    'If SourceRange use all columns then skip this file
                    If SourceRange.Columns.Count >= BaseWks.Columns.Count Then
                        Set SourceRange = Nothing
                    End If
                End If
                On Error GoTo 0
    
                If Not SourceRange Is Nothing Then
    
                    'Find the last row in BaseWks
                    rnum = RDB_Last(1, BaseWks.Cells) + 1
    
                    With SourceRange.Parent
                        Set rng = Nothing
    
                        'Firstly, remove the AutoFilter
                        .AutoFilterMode = False
    
                        'Filter the range on the FilterField column (Weeks to Go)
                        SourceRange.AutoFilter Field:=FilterField, _
                                            Criteria1:=FilterValue1, _
                                            Criteria2:=FilterValue2
                      
                        With .AutoFilter.Range
                            'Check if there are results after you use AutoFilter
                            RwCount = .Columns(1).Cells. _
                                      SpecialCells(xlCellTypeVisible).Cells.Count - 1
    
                            If RwCount = 0 Then
                                'There is no data, only the header
                            Else
                                'Set a range without the Header row
                                Set rng = .Resize(.Rows.Count + 1, .Columns.Count). _
                                          Offset(1, 0).SpecialCells(xlCellTypeVisible)
    
                                If FileNameInA = True Then
                                    'Copy the range and the file name
                                    If rnum + RwCount < BaseWks.Rows.Count Then
                                        BaseWks.Cells(rnum, "A").Resize(RwCount).Value _
                                              = mybook.Name
                                        rng.Copy BaseWks.Cells(rnum, "B")
                                    End If
                                Else
                                    'Copy the range
                                    If rnum + RwCount < BaseWks.Rows.Count Then
                                        rng.Copy BaseWks.Cells(rnum, "A")
                                    End If
                                End If
                            End If
                        End With
    
                        'Remove the AutoFilter
                        .AutoFilterMode = False
    
                    End With
                End If
    
                'Close the "JOB CHECKLIST *" without saving
                mybook.Close savechanges:=False
            End If
    
            'Open the next workbook
        Next I

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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