Posts by ir121973

    Re: VBA Extract Highest and Second Highest Values


    Hi apo, thank you very much for taking the time to reply to my post and form putting the solution togther which works great.


    May I just ask please, if I wanted to change the first 'Destination' cell from J to K, in addition to the changes that need to be made on this line:

    Code
    For Each rng1 In Sheets(2).Range("J7:J" & Sheets(2).Range("J" & Rows.Count).End(xlUp).Row)

    what other lines would need to be amended please?


    May I also ask one more favour, would it be at all possible for you to insert some notes into the code please which explains which each part of the code does, because I am very keen to learn as I go along.


    Many thanks and kind regards

    Hi, I wonder whether someone may be able to help me please.



    I'm attempting to put together a script which in simple terms finds the 'Highest and Second' highest activity and associated FTE for a given sub group.



    To be more specific:


    • On the "Slide 1" sheet look at the values in column J starting at row 7 until blank;
    • For each value, then search the "All Monthly Direct Activities" sheet in column C for the same value, excluding the 'Subtotal' rows;
    • Where a match is found, compare all the values in column E for that sub group;
    • And Find the highest and second highest figure;


    Once these are found copy this figure and associated value in column B and paste onto the "slide 1" sheet.



    I have posted on ExcelForum here http://www.excelforum.com/exce…cond-highest-figures.html and did receive some help as you will see but I still have an outstanding issue.


    I'm not particularly well versed in writing VB, but I've been working with the code to see if I can get this work, which I have been unable to do.


    I have attached a file which may perhaps provide a greater detail than my description of the problem containing the 'Source' and 'Destination' sheets.


    I just wondered whether someone could possibly look at this please and feel they may be able to help



    Many thanks and kind regards

    Hi, I wonder whether someone may be able to help me please.


    I'm using the following array formula in cell M7 on my sheet:


    Quote

    =SUM(--(FREQUENCY(IF((JRole=K7)*(Period=B3)*(PLOB=M6)*(PName<>"*DIR*")*(PName<>"*Enhancements*")*(PName<>"*IND*")*(PName<>"*OVH*")*(SName<>""), MATCH(SName,SName&"",0)),ROW(SName)-ROW(B4)+1)>0))

    The formula works fine, but my problem is two fold.


    • I'd now like to extend the formula so that it is present in every cell in the range M7:U7, with the 'PLOB=M6' element of the formula changing to the current cell minus 1 row, which I'm very unsure of how to do,
    • The other issue I have is that this formula causes the spreadsheet to run slow. This will only be


    exacerbated when all of the formula have been added, so I wonder whether I may need to use a VB script


    As you are probably aware, I'm unsure how to progress this, so I just wondered whether someone may be able to look at this please and offer some guidance on how I may go about resolving this.


    Many thanks and kind regards

    Hi, I wonder whether someone may be able to help me please.


    I'm using the code below to create and format a sheet within my workbook.



    The code wotrks fine, but I'm aware it's a little messy and perhaps a little longer than it needs to be.


    I just wondered whether someone, perhaps with a greater experience than I, may be able to look at this please and offer some guidance on how I may go about tidying this up.


    Many thanks and kind regards

    Re: VBA Display Input Box and Extract Files


    Hi holycow, since your last post I've been working on this and by using two posts I found on this site here http://www.ozgrid.com/forum/showthread.php?t=59228 & http://www.ozgrid.com/forum/showthread.php?t=69382 I've been able to move my script on considerably and I've been able to get this to work.


    For info, my code is now as follows:



    Many thanks for your time trouble and patience.

    All the best and kind regards

    Re: VBA Display Input Box and Extract Files


    Hi holycow, thank you very much for taking the time to reply to my post.


    I'm now working on the file at home, so my file path has changed to

    Code
    sFile = "\\D:WorkFiles\" & mo & "\Time Recording\ & "

    but I am still receiving the error, which I suppose in some respects is good news.


    As you suggested I went into the 'Immediate' window and the results were as follows:

    Quote

    D:\Work Files\Extract Macro.xls

    with "Extract Macro" being the name of my file.


    Many thanks and kind regards

    Hi, I wonder whether someone may be able to help me please.


    I'm trying to put together a script which performs the following:


    • Display a Input Box to user
    • User enters a month name
    • Once a month has been selected open the "Time Recording" folder automatically and extract the files automatically, copying pertinent data, pasting this into a "Summary" sheet.



    The problem I have is that when I run this I recieve the following error: "\\Irf01234\ims r and d management\D&RM\Reporting\Chris Test\November\Time Recording.xls" cannot be found.


    Debug then highlights this line as the cause:

    Code
    Set wb = Workbooks.Open(Filename:=sFile, ReadOnly:=True, Password:="master")


    When the 'Input Box' is displayed to the user, the file path should be

    Code
    "\\Irf01234\ims r and d management\D&RM\Reporting\Chris Test\


    The user then types the month name e.g. November so the file path will become

    Code
    "\\Irf01234\ims r and d management\D&RM\Reporting\Chris Test\November

    I would then like the script to automatically open the "Time Recording" folder and automatically open and extract the data from the files within the "Time Recording" folder.


    I just wondered whether someone could possibly look at this please and let me know where I'm going wrong.


    Many thanks and kind regards

    Re: VBA Browse &amp; Extract From Multiple Files


    Hi cytop, thank you for taking the time to reply to my post, and my apologies for not getting back to you sooner.


    I've now amended my script to the following which doesn't as yet, overcome the password issue, but it allows the user to select the files to open.



    However, I would like to adapt this a little so that the user only has to select the folder to open and the files open automatically.


    I just wondered whether you may be able to offer some guidance on how I may go about achieving this.


    Many thanks and kind regards

    Hi, I wonder whether someone may be able to help me please.


    I'm using the code below to automatically open multiple password protected files and extract pertinent data from each, amalgamating them into a "Summary" sheet.




    In it's current form, the filepath and password for each file are hardcoded into a sheet called "File List", and are read in this piece of code:


    Code
    FileNames = ThisWorkbook.Worksheets("File List").Range("B4:B11").Value
        For n = LBound(FileNames, 1) To UBound(FileNames, 1)
            
        Set wb = Workbooks.Open(Filename:=FileNames(n, 1), ReadOnly:=True, Password:=ThisWorkbook.Worksheets("File List").Range("C4:C11").Cells(n).Value)


    All of the 'Source' files will be located in monthly folders, so I'm looking to amend the code so the user can browse and select the folder they wish to extract the files from.


    I've found quite a few examples of creating a script which allows the user to brosw for a folder, but I'm having difficulty in trying to open the password protected files and then extract the pertinent data.


    I just wondered whether someone may be able to look at this please and offer some guidance on how I may go about achieving this.


    Many thanks and kindm regards

    Re: VBA Loop At Each Value Change


    HI PCI, thank you for taking the time to reply to my post and for the suggestion.


    I had thought of using a Pivot table, but some of my colleagues using this have very limited Excel knowledge, and in addition, as this will be part of a larger script I was trying to put together a VB script.


    Many thanks and kind regards

    Hi, I wonder whether someone may be able to help me please.


    I'm trying to put together a script which look at the "Monthly Projects" and create a loop that will take the info from each row in column B and group it by the data in column C. In addition I would like to to 'Sum' the values in column E for each change in column C. I would then like to paste this data into the sheet "Slide 1".


    It's a little difficult to explain, so I have attached a file, showing the raw data on the "Monthly Projects" sheet, sheet "Slide 1" where I would like to paste the data to, and sheet "Slide 1 Expected Outcome" displaying how I would like, if at all possible the extracted data to look.


    I have to admit I'm not even sure where to start, and I've been unable to find post/examples which perform the data extraction within a loop.


    I just wondered whether someone could possibly look at this please and offer some guidance on how I may go about achieving this.


    Many thanks and kind regards

    Re: VBA Insert Row and Subtotal


    Hi cytop, thank you for taking the time to reply.


    Yes, you're quite right, but I was hoping to keep manual intervention to a minimum for the project I'm working on because some of the staff who will be using this, have a very, very limited knowledge of Excel.


    Many thanks and kind regards

    Hi, I wonder whether someone may be able to help me please.


    I have a dynamic sorted list, ranging from columns B:F with headers in row 4 and the data starts in row 5, and I'm trying to put together a script which performs the following:


    • Look for each change in column C ,
    • Where this occurs insert a new row below, and insert the text "Subtotal for (then the text value of the group)" in column C, and
    • Then sum the values in columns D, E and F


    I've spent quite a bit of time researching this and I came across the following example http://www.mrexcel.com/forum/e…h-change-sorted-list.html


    and I've tried to use the following code from this post, but I've been unable to get this to work:



    I just wondered whether someone may be able to look at this please and offer some guidanced om how I may be able to achieve this.


    Many thanks and kind regards