+ Reply to Thread
Results 1 to 20 of 20

Traverse matrix and loop help

  1. #1
    Registered User
    Join Date
    07-05-2017
    Location
    chicago
    MS-Off Ver
    Office 2013
    Posts
    44

    Traverse matrix and loop help

    Good Morning,

    Can anyone help with a complicated VBA?

    I need the VBA to go into two tabs (flat fee and phase tier) in each excel workbook and pull the data out (they will sit in a specific folder).

    I have coded the data into two separate arrays- A9:A80 and then D4:GJ4 for each tab, so basically I need to loop and pull the file in by row and by column. See attached workbooks. There will be about 60 of the excel files, so that’s why I need a macro to help.

    I think the result of the macro would look like this: so it would pull in every data field in all of the excel tabs for D4:GJ4 and then cross reference to the data array A9:A80 (in this case city/state) and populate.

    Is this even a possibility?

    I attached a sample workbook and then a picture of what I think the end goal is.end goal.png
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    6,274

    Re: Traverse matrix and loop help

    Where do you get the 1200, 600, 800... etc. values? There was nothing in the workbook....
    Bernie Deitrick
    Excel MVP 2000-2010

  3. #3
    Registered User
    Join Date
    07-05-2017
    Location
    chicago
    MS-Off Ver
    Office 2013
    Posts
    44

    Re: Traverse matrix and loop help

    Hi,

    I just typed those in quickly as an example of how I'd like the macro to return data. I can see the data in the excel book I attached, not sure why it wouldn't work for you.

  4. #4
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    6,274

    Re: Traverse matrix and loop help

    I see the labels and column headers, but everything else is blank. So, I'm not sure what you want done with those...

  5. #5
    Registered User
    Join Date
    07-05-2017
    Location
    chicago
    MS-Off Ver
    Office 2013
    Posts
    44

    Re: Traverse matrix and loop help

    Hi there, this is a bid form. So it will be sent out to Law Firms to bid on it. They will fill in pricing in the blank cells where applicable. I am looking to write a macro which will summarize the data in the example above. So basically I would need the macro to loop through the rows/columns specified to return all of the values in a large number of workbooks that will be sent out and filled in.

  6. #6
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    6,274

    Re: Traverse matrix and loop help

    What would you want entered into cells if two or more files have the same cell filled in but with different values?

    Instead of the format that you are suggesting, it might be better to create a database from only the filled values (Law Firm Name, Row label, column label, value, and other information if needed) that could then be filtered to show a value of interest.

  7. #7
    Registered User
    Join Date
    07-05-2017
    Location
    chicago
    MS-Off Ver
    Office 2013
    Posts
    44

    Re: Traverse matrix and loop help

    Hi Bernie, two or more files would never have the same cell filled in, since each file will be a different law firm. The unique identifier would hold the law firm name (the first 5 letters) the file type, and the pricing type.

  8. #8
    Registered User
    Join Date
    07-05-2017
    Location
    chicago
    MS-Off Ver
    Office 2013
    Posts
    44

    Re: Traverse matrix and loop help

    So where it says "Test2" that is actually going to be the law firm name. In each excel workbook, the name will be unique.

  9. #9
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    6,274

    Re: Traverse matrix and loop help

    Try the macro below - copy the code into a standard codemodule in an otherwise blank workbook, and run the macro "GetDataFromBidBook" and choose one of your bid files when prompted. Then try it a second time, choosing a different workbook. If the code works, it can be modified to allow the selection of all your files in one go instead of one at a time.

    The code creates a database that can be filtered by county, to show the different values bid for that county. The second column can be filtered using the "Contains" text option to look for a specific service.

    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    07-05-2017
    Location
    chicago
    MS-Off Ver
    Office 2013
    Posts
    44

    Re: Traverse matrix and loop help

    Thank you for the code! I cannot get it to work. I filled out a dummy bid sheet with numbers. It's called test 2. then the macro is in the macro workbook. Can you take a peek?
    Attached Files Attached Files

  11. #11
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    6,274

    Re: Traverse matrix and loop help

    The workbook that you posted the first time had only two sheets, and the workbook that you are using had six worksheets (three of which were hidden). And it had formulas in the range of cells where the users would enter their values - my code was looking for constants, not formulas. Macro code is specific enough that things like that matter. So, anyway, try this version, which looks for two "Pricing" sheets, and converts everything to values before proceeding (but does not over-write the original workbook, so it won't matter):

    Please Login or Register  to view this content.

  12. #12
    Registered User
    Join Date
    07-05-2017
    Location
    chicago
    MS-Off Ver
    Office 2013
    Posts
    44

    Re: Traverse matrix and loop help

    OMG that worked! Thank you so much!!!!

  13. #13
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    6,274

    Re: Traverse matrix and loop help

    Great! Thanks for letting me know that my code worked for you.

  14. #14
    Registered User
    Join Date
    07-05-2017
    Location
    chicago
    MS-Off Ver
    Office 2013
    Posts
    44

    Re: Traverse matrix and loop help

    Hi Bernie- I have to make some changes to format the data differently.

    Quick overview, I need to go into each "firm name" excel file within a folder and pull out data from the flat fee tab and the phase tier tab. Some data sets need to be transposed and some do not. I would like to pull the "Flat fee data into the flat fee tab on the input file, and the phase tier data into the phase tier tab on the input file) When this is done for one firm, I would like the file to close and then open the next firm and do the same thing.


    1. Logic to pull several excel files from a specific folder/directory extract data and then close and move to the next. Let's call the folder/directory "Wisconsin" so I can easily spot and change it to the actual directory in the code.

    2. Logic to open file named "Firm A" (which sits in the folder Wisconsin) and go into the tab named "Fixed Fee Pricing" and pull in the Firm name in cell B2 (return this firm name to the input file in the flat fee tab cell C1).

    3.Logic to pull the "Fixed Fee Pricing" data from A8:A79 and return it to input tab "Flat Fee" A2 and going down.

    4.Logic to pull the "Fixed Fee Pricing" data from D4 to W4 and return it to input tab "Flat Fee" B2 and going down.

    5. Logic to pull the "Fixed Fee Pricing" data from D8:W92 and match up by column A and row 4 (so matching it by county/symbol) and then transpose it and return to input tab C2 and down.

    so basically I want to lookup the county state, the symbol type and the fee and return it in the three columns in the input file by firm name (firm names to populate C1,D1,E1, etc.... ) with the pricing, county state and symbol going down.

    Same thing for the Phase tier tab.


    Then I want Firm A to close, and Firm B to open and populate all of the data in D1 going down. - Only the price though, since the county state and input file will have already been populated.





    I am attaching the "Wisconsin" file that I would like to have the macro in, and then the Firm A and Firm B.
    Attached Files Attached Files

  15. #15
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    6,274

    Re: Traverse matrix and loop help

    I have no idea what you want at the end of all this: the range D8:W92 is completely filled, so why do you only want to fill column C from that range? Could you modify your input file to show what data you want in columns A to C based on your file Firm A.xlsx?

  16. #16
    Registered User
    Join Date
    07-05-2017
    Location
    chicago
    MS-Off Ver
    Office 2013
    Posts
    44

    Re: Traverse matrix and loop help

    Sorry I am really struggling with the correct language.

    Ok, I updated the input file, "Phase Tier" tab.

    So, in the input workbook, I will need column A to populate every county/state from Firm A "Phase Tier Pricing". There will need to be 180 of each county in Column A in the input tab since there are 180 unique types of pricing. Basically, each county has 180 different types of pricing.

    Then, I need to pull the file types from Firm A (row 4) and transpose to input file column B. These will need to repeat for each of the 72 counties. So Esentially, there should be 12,960 rows going down.

    Lastly, I need the macro to open every Firm file in the main folder and dump the name into the input file (column C1, D1, E1, F1) and then look up the price according to county and file type and return the rice in column C. Then the macro will close Firm A, and open firm B and populate the firm name in D1 and then return the pricing in column D.

    Does that make more sense?

    Then, I will need to This is a one time dump, once Firm a is populated, firm B and C and D etc... will all have the same counties. So I will only need the macro to pull in the appropriate prices.

    I would like column B in the input file to populate the file types (WC_T3_P1)
    Attached Files Attached Files

  17. #17
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    6,274

    Re: Traverse matrix and loop help

    Try this in your input.xlsm. Select the file(s) of interest when prompted

    Please Login or Register  to view this content.

  18. #18
    Registered User
    Join Date
    07-05-2017
    Location
    chicago
    MS-Off Ver
    Office 2013
    Posts
    44

    Re: Traverse matrix and loop help

    Wow, that is amazing. Thank you so much for your help!!!

  19. #19
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    6,274

    Re: Traverse matrix and loop help

    You're welcome! Have fun transforming your data!

  20. #20
    Registered User
    Join Date
    07-05-2017
    Location
    chicago
    MS-Off Ver
    Office 2013
    Posts
    44

    Re: Traverse matrix and loop help

    Hi- I have a huge favor to ask. I had to add a section to one of my tabs and now the macro is not working. Can you review?
    Attached Files Attached Files

+ 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. Optimize Macro- creating binary matrix out of data information- nested loop
    By simz92 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 02-06-2017, 04:15 AM
  2. Replies: 6
    Last Post: 11-18-2013, 11:28 PM
  3. [SOLVED] Traverse data from one excel tab to another in same file.
    By Ali79 in forum Excel General
    Replies: 8
    Last Post: 09-25-2012, 09:30 AM
  4. [SOLVED] VBA: Loop through cells in matrix and return column- and row headers
    By Søren Larsen in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-25-2012, 08:43 AM
  5. Traverse a colum match a text and return sum of all values in adjacent cells
    By realdost in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-23-2012, 09:49 PM
  6. Recursively traverse through a range and assign a value to each cell in range
    By itzchau in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-11-2010, 12:44 PM
  7. traverse until non integer
    By evil baby in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-01-2006, 12:10 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