+ Reply to Thread
Results 1 to 18 of 18

Transfer and filter docments.

  1. #1
    Registered User
    Join Date
    06-29-2016
    Location
    Ireland
    MS-Off Ver
    2019
    Posts
    47

    Transfer and filter docments.

    Hello, I need a hand here with some VBAs as I'm completely lost.
    1)
    I needed a vba that transfer documents inserted in an interface in one worksheet to a consultation list split into sections in another worksheet. The document name is the result of 11 fields inserted in the interface and concatenated. The first character on the fields 8 will define in each section the document will go to the consultation list.
    2) Once in the consultation list, I needed to create 3 filters (by date, by field 8 type (can be various types) and by field 5 (can be of various types too)) but the filters should bring only the latest version of the document, comparing the 8 first fields, and returning the most recent according to date and (if necessary) the time.

  2. #2
    Registered User
    Join Date
    06-29-2016
    Location
    Ireland
    MS-Off Ver
    2019
    Posts
    47

    Re: Transfer and filter docments.

    Sorry, I forgot to attached a simple schematics for a better understanding. Here now.

    Document Register Schematics.jpg

  3. #3
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,239

    Re: Transfer and filter docments.

    Will you please attach a small sample Excel workbook? We are not able to work with or manipulate a picture of one and nobody wants to have to recreate your data from scratch.

    1. Make sure that your sample data are REPRESENTATIVE of your real data. The use of unrepresentative data is very frustrating and can lead to long delays in reaching a solution.

    2. Make sure that your desired results are also shown (mock up the results manually).

    3. Make sure that all confidential data is removed or replaced with dummy data first (e.g. names, addresses, E-mails, etc.).

    4. Try to avoid using merged cells as they cause lots of problems.

    Unfortunately the attachment icon doesn't work at the moment, so to attach an Excel file you have to do the following: just before posting, scroll down to Go Advanced and then scroll down to Manage Attachments. Now follow the instructions at the top of that screen.

    Please pay particular attention to point 2 (above): without an idea of your intended outcomes, it is often very difficult to offer appropriate advice.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  4. #4
    Registered User
    Join Date
    06-29-2016
    Location
    Ireland
    MS-Off Ver
    2019
    Posts
    47

    Re: Transfer and filter docments.

    Hello ALIGW,
    Thank you very much for the cerity in the answer. I have the excel here but really cannot upload it despite instructions already read.
    Please could you explain in baby steps?
    Regards,

  5. #5
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,239

    Re: Transfer and filter docments.

    Look (scroll) down right - find the Go Advanced button - click it.

    Now look down again - find the Manage Attachments link in blue - click it.

    Browse to your file - upload - close.

    Write your post - save/submit.

  6. #6
    Registered User
    Join Date
    06-29-2016
    Location
    Ireland
    MS-Off Ver
    2019
    Posts
    47

    Re: Transfer and filter docments.

    Hello, I'm just repeating the post posted at the top to facilitate.
    I would like some help in:
    1) A VBA to transfer documents inserted in an interface in one worksheet to a consultation list split into sections in another worksheet. The document name is the result of 11 fields inserted in the interface and concatenated. The first character on the fields 8 will define in each section the document will go to the consultation list.
    2) Once in the consultation list, I needed to create 3 filters (by date, by field 8 type (can be various types) and by field 5 (can be of various types too) being cumulative one to the other(s)) but the filters must compare the first 8 fields of the document name and bring only the latest version submitted. A date field can be useful for this but in the eventuality of having two documents submitted with the same date, then maybe another way (inserting a field with the time?) to filter them.
    There is more details in the model. I tried to be as detailed as I could but please let me know if there is anything else I can clarify.
    Thank you!!!
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    06-29-2016
    Location
    Ireland
    MS-Off Ver
    2019
    Posts
    47

    Re: Transfer and filter docments.

    Hello guys,
    I was able to write a code for the first part of the task (evaluate field 8 and paste it on the sheet LOG) but this is certainly very archaic as I couldn't produce a decent loop for it so I had to copy 4 times the same code (for the 4 Series I have) and will need to produce 9 more codes for all 10 rows in the sheet Input. At least it works.... Or doesn't it?...
    The main problem I'm having it here (in addition to the ugly code itself) is that when I try to put all codes together in a CALL module, I don't know why the 2nd module it's not working. If I run them separately, it's ok, though. I tried putting them in the same module and separate (Call) but no joy.
    Could anybody tell me why it's not working together or give me a hand on how to write a loop for all the conditions?
    Much appreciated!
    Attached Files Attached Files

  8. #8
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,239

    Re: Transfer and filter docments.

    Thanks for the PM. I have reviewed your post as requested. I am not sure why you are not getting any responses, but I’ll put out a plea for help to see if we can Husarenritt things along for you.

  9. #9
    Registered User
    Join Date
    06-29-2016
    Location
    Ireland
    MS-Off Ver
    2019
    Posts
    47

    Re: Transfer and filter docments.

    I love this forum. In addition to Excel I generally learn new words and other stuff as well (Husarenritt)

  10. #10
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,239

    Re: Transfer and filter docments.

    Well, so have I! My iPad clearly knows better than I do ... I meant hurry things along.

    Husarenritt - German for cavalry charge, I think.

  11. #11
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,594

    Re: Transfer and filter docments.

    Try this for starters:
    Please Login or Register  to view this content.
    Ben Van Johnson

  12. #12
    Registered User
    Join Date
    06-29-2016
    Location
    Ireland
    MS-Off Ver
    2019
    Posts
    47

    Re: Transfer and filter docments.

    Hello Proton Leah,

    Thank you very much. It works perfectly. There was a mistake I made naming the series but after fixing it and changing the ranges (I had to change a bit due to visual inserts) it works fine. The only thing is that is a bit slow on my PC to process (i7, 16gb RAM), but I can totally live with that.
    Let me ask you something very silly but it took me almost a day and I couldn't solve it. Why I couldn't call the separate codes as I had in a master code (please see TIE code)? I revised loads of times but couldn't find a mistake.
    Also, is there any hope to achieve the filter functionalities I intend in the worksheet LOG? I'm trying something here at the moment but if I was able to do something in the first part, this is way above my "pay grade"! If you could give me a had here I really appreciate.
    Regards,
    Attached Files Attached Files

  13. #13
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,594

    Re: Transfer and filter docments.

    Your "Tie" codes ran ok for me...
    I don't understand your filter problem, sorry...

  14. #14
    Registered User
    Join Date
    06-29-2016
    Location
    Ireland
    MS-Off Ver
    2019
    Posts
    47

    Re: Transfer and filter docments.

    Both codes 1 and 2? Without any changes? Strange...

  15. #15
    Registered User
    Join Date
    06-29-2016
    Location
    Ireland
    MS-Off Ver
    2019
    Posts
    47

    Re: Transfer and filter docments.

    Hello protonLeah,
    In the sheet LOG, where all the documents are stored, I need to filter by series, by field 5 and by field 8 via drop downs.
    But I need that only the most recent files (ruled by the date) to be presented. Example: I can have two documents that have exactly the same fields in the name (from fields 1 to 8) but different dates so I need only the most recent one to be filtered. Can I achieve this with VBA?
    Attached Files Attached Files

  16. #16
    Registered User
    Join Date
    06-29-2016
    Location
    Ireland
    MS-Off Ver
    2019
    Posts
    47

    Re: Transfer and filter docments.

    Good evening,
    Please could anybody offer some help. I'm really going crazy with this one!
    After several attempts to do the one above, I have changed the purpose a few times to see if I can get this working.
    I'm trying to create a document log register in which you input the criteria you need on worksheet INPUT and use the vba Record (from protonLeah below and working perfectly) to record them on the worksheet LOG.
    After that. when I use the worksheet INPUT again, I need a vba to compare range NAME (worksheet INPUT T20:T29) with all the files recorded on the worksheet LOG (Range C:C). If the files are not there, the code from protonLeah will run normally and copy them all again but if there is one or more repeated, I would need the repeated ones to be copied over the ones already in the LOG. (erase the old record and then copy the new one).
    If somebody could give me a hand here I really appreciate.
    Attached Files Attached Files

  17. #17
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,594

    Re: Transfer and filter docments.

    Try adding an additional sub to find and delete old recs.:
    Please Login or Register  to view this content.
    new sub:
    Please Login or Register  to view this content.

  18. #18
    Registered User
    Join Date
    06-29-2016
    Location
    Ireland
    MS-Off Ver
    2019
    Posts
    47

    Re: Transfer and filter docments.

    Hello protonLeah,

    I would like to thank o=you once more for the help so far.

    I forgot everything about what I've done before and just pasted your two codes together along with a few lines added to obtain the desired result as per below:

    PHP Code: 
    Sub Register()

    If 
    Evaluate(WorksheetFunction.CountIf(Range("AS"), "ALREADY SUBMITTED")) <> 0 Then
    MsgBox 
    "One or more documents already submitted!"
    Exit Sub
    End 
    If

        
    Dim LogName     As Range_
            TestName    
    As Range_
            InputNames  
    As Range_
            WrkRng      
    As Range
            
        Set InputNames 
    Sheets("INPUT").Range("T20:T29")
            
        
    With Sheets("REGISTER")
            
    Set WrkRng = .Cells(.Rows.Count"C").End(xlUp)
            
    Set LogName = .Range("C19"WrkRng)
        
    End With
            
        
    For Each TestName In InputNames
            Set WrkRng 
    LogName.Find(TestName)
            If 
    Not WrkRng Is Nothing Then
                WrkRng
    .EntireRow.Delete
            End 
    If
        
    Next TestName
        
           Dim SeriesList  
    As Range_
            SeriesNum   
    As Range_
            DestRange   
    As String
            
            Set SeriesList 
    Sheets("INPUT").Range("L20:L29")
            For 
    Each SeriesNum In SeriesList
                DestRange 
    "S_" Left(SeriesNum.Value1)
            
            
    With Sheets("REGISTER").Range(DestRange)
                .
    Offset(RowOffset:=1).EntireRow.Insert _
                    Shift
    :=xlDown
                
    .Offset(RowOffset:=2).EntireRow.Copy
                
    .Offset(RowOffset:=1).EntireRow.PasteSpecial
                Application
    .CutCopyMode False

                
    .Offset(1, -10).Value Worksheets("INPUT").Range("T" SeriesNum.Row).Value
                
    .Offset(1, -9).Value Worksheets("INPUT").Range("S" SeriesNum.Row).Value
                
    .Offset(1, -3).Value Worksheets("INPUT").Range("L" SeriesNum.Row).Value
                
    .Offset(10).Value Worksheets("INPUT").Range("U" SeriesNum.Row).Value
                
    .Offset(14).Value Worksheets("INPUT").Range("N" SeriesNum.Row).Value
                
    .Offset(15).Value Worksheets("INPUT").Range("O" SeriesNum.Row).Value
                
    .Offset(16).Value Worksheets("INPUT").Range("P" SeriesNum.Row).Value
            End With
        Next SeriesNum
        
    Sheets
    ("REGISTER").Select
    Range
    ("N20").Select

    Sheets
    ("Input").Activate
    Range
    ("F20:H29").ClearContents
    Range
    ("J20:P29").ClearContents
        
    End Sub 
    Main problem here is: When I have one of the rows empty, the code breaks always on the "With Sheets("REGISTER").Range(DestRange)" line.

    Is there a way to test if the row is empty (can be verified using the cells S20:S29 where I have my concatenation) and "do nothing" with the empty row and keep going with the code?

    Regards,

+ 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. [SOLVED] Filter and transfer fixed number to created sheet
    By YasserKhalil in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 04-14-2016, 01:27 AM
  2. Insert word docments into Excel spreadsheet - "Can not insert object" error
    By GerryPeterson in forum Excel - New Users/Basics
    Replies: 2
    Last Post: 11-25-2015, 07:37 PM
  3. Error handling in Filter if no record found to be transfer
    By emina002 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-07-2014, 09:51 AM
  4. [SOLVED] Required VBA for filter data & transfer data
    By santosh226001 in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 06-02-2014, 02:09 AM
  5. Automatic filter and transfer data on other workbook
    By vintan in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 03-16-2013, 03:59 AM
  6. How do I transfer User-Defined filter parameters to then filter another column?
    By fiqulupo in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-28-2012, 07:05 PM
  7. Replies: 0
    Last Post: 06-21-2011, 10:40 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