+ Reply to Thread
Results 1 to 45 of 45

Looping macro

  1. #1
    Registered User
    Join Date
    05-16-2008
    Posts
    31

    Looping macro

    I am trying to get data from Sheet Project_Pipeline Column D1, Match it to Row A1 in the DayView and continue until D1 is empty. I can only get it to copy and paste 1 section of data.

    Please Login or Register  to view this content.
    Last edited by VBA Noob; 05-16-2008 at 03:18 PM.

  2. #2
    Forum Contributor stevebriz's Avatar
    Join Date
    09-07-2006
    Location
    Santiago Chile
    Posts
    389
    Can you post a sample of your xls?
    VBA - The Power Behind the Grid

    Posting a sample of your workbook makes it easier to look at the Issue.

  3. #3
    Registered User
    Join Date
    05-16-2008
    Posts
    31
    Quote Originally Posted by stevebriz
    Can you post a sample of your xls?
    Here is my .xls
    Attached Files Attached Files

  4. #4
    Forum Contributor stevebriz's Avatar
    Join Date
    09-07-2006
    Location
    Santiago Chile
    Posts
    389
    I'm having trouble opening the attachment .Can you zip it and repost it?

  5. #5
    Registered User
    Join Date
    05-16-2008
    Posts
    31
    Try this one.
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    05-16-2008
    Posts
    31
    And thanks for your assistance.

  7. #7
    Forum Contributor stevebriz's Avatar
    Join Date
    09-07-2006
    Location
    Santiago Chile
    Posts
    389
    Hi again
    I little confused at what you are trying to achieve.

    I am trying to get data from Sheet Project_Pipeline Column D1, Match it to Row A1 in the DayView and continue until D1 is empty. I can only get it to copy and paste 1 section of data.
    For each of the dates in the dayview in Row 1 , Do you want to search thorugh the pipeline sheet column D and find a matching Date then if the date matches copy the corresponding persons name to the next available cell below the date your are searching for? in the Dayview?
    After finding the corresponding names for the dayview date in A1 move to B1 and search and copy as you did for the A1 date? then continue to with the same process for all dates up to cell N1 in the dayview

    If it is not this can you please explain step by step??

  8. #8
    Registered User
    Join Date
    05-16-2008
    Posts
    31
    For each of the dates in the dayview in Row 1 , Do you want to search thorugh the pipeline sheet column D and find a matching Date then if the date matches copy the corresponding persons name to the next available cell below the date your are searching for? in the Dayview? Correct.

  9. #9
    Forum Contributor stevebriz's Avatar
    Join Date
    09-07-2006
    Location
    Santiago Chile
    Posts
    389
    Try this:
    Put in a module.
    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    05-16-2008
    Posts
    31
    Steve,
    You are the best.... Thanks!!!!

  11. #11
    Registered User
    Join Date
    05-16-2008
    Posts
    31
    Steve,
    Can you help me some more?

  12. #12
    Registered User
    Join Date
    05-16-2008
    Posts
    31
    So what I am needing now is this.
    1. Compare Date in Project_Pipeline D, H, I, J, K and if they match what is DayView Column 14 and Row C then paste Project_Pipeline C into that cell for each, and color code them by Project_Pipeline B According to the color Table in DayView. I have attached the Excel.
    Attached Files Attached Files

  13. #13
    Forum Contributor stevebriz's Avatar
    Join Date
    09-07-2006
    Location
    Santiago Chile
    Posts
    389
    I will have a look

  14. #14
    Forum Contributor stevebriz's Avatar
    Join Date
    09-07-2006
    Location
    Santiago Chile
    Posts
    389
    Sorry but I am confused as to what you want.
    Cell C14 on the the dayview is a category.
    If for Example the category is business do you want to color all the "Business" cells in the project _pipeline sheet.
    But what color corresponds to "Business"????
    For all the other cells that are not "Business"...these are not colored?? Correct?

    I am also not sure what the relationship between the "Activity color key" colors and the the data on the project pipeline sheet??? Please can you explain?

  15. #15
    Registered User
    Join Date
    05-16-2008
    Posts
    31
    I was wanting to that on Project_Pipeline B Row, that if it is one of the below, that we I copied it to the DayView Sheet, it color codes that cell it pasted the Project_Pipeline Row C data from.
    On the DayView I have a the Activity Color Key for each.
    Device
    Site Visit
    Operations
    Marketing
    Training
    Product
    System
    Communication
    WFM
    SMCC

  16. #16
    Forum Contributor stevebriz's Avatar
    Join Date
    09-07-2006
    Location
    Santiago Chile
    Posts
    389
    Try this:

    Please Login or Register  to view this content.

  17. #17
    Registered User
    Join Date
    05-16-2008
    Posts
    31
    Steve,
    That works for the color coding, but it's not for the data validation and copying of data from Project_Pipeline H, I , J and K to the matching DayView LOBs, any ideas?

  18. #18
    Forum Contributor stevebriz's Avatar
    Join Date
    09-07-2006
    Location
    Santiago Chile
    Posts
    389
    I'm still confused ..which columns do u want to copy the Project_Pipeline H, I , J and K in the DayView ?
    Make you can put some comment in the spread sheet to illustrate ?

  19. #19
    Registered User
    Join Date
    05-16-2008
    Posts
    31
    Sorry for not being clear. See if this Helps
    Attached Files Attached Files

  20. #20
    Registered User
    Join Date
    05-16-2008
    Posts
    31
    Steve,
    Is that possible?

  21. #21
    Forum Contributor stevebriz's Avatar
    Join Date
    09-07-2006
    Location
    Santiago Chile
    Posts
    389
    I think I am starting to understand what you want.
    In Essence you want to add a record in the dayview multiple times relative to if it is memebr of each category..business,national support etc as shown in columns H,I J, K. for the rocrd

    Previously the macro would just the record once without category in column C
    But you want to duplicate the same record each time it has Consumer, Business Employee , National Sales Support in the columns H-K ? Correct or No?

  22. #22
    Registered User
    Join Date
    05-16-2008
    Posts
    31
    That is correct.

  23. #23
    Forum Contributor stevebriz's Avatar
    Join Date
    09-07-2006
    Location
    Santiago Chile
    Posts
    389
    Give this one ago.
    (You should remove the text you wrote for me from before running this or it will format column A with a huge width!
    Please Login or Register  to view this content.

  24. #24
    Registered User
    Join Date
    05-16-2008
    Posts
    31
    It does not appear to be doing what I am wanting.

  25. #25
    Forum Contributor stevebriz's Avatar
    Join Date
    09-07-2006
    Location
    Santiago Chile
    Posts
    389
    Can you explain in what way.???
    Remember that you ahve autofilters there.. so You need to se all in columns c and d to show all records.

  26. #26
    Registered User
    Join Date
    05-16-2008
    Posts
    31
    It's not Validating Project_Pipeline H, I, J, K and populating Project Pipe Line C into DayView by Date and Column C LOB.
    I want it to double Validate Date = in Project_Pipeline and DayView and LOB DayView (Column C) = one or all Project_Pipeline H, I, J, K.

    I attached the output from the current Module
    Attached Files Attached Files

  27. #27
    Registered User
    Join Date
    05-16-2008
    Posts
    31
    Steve,
    Any ideas on this?

  28. #28
    Forum Contributor stevebriz's Avatar
    Join Date
    09-07-2006
    Location
    Santiago Chile
    Posts
    389
    When you made some changes it stopped working ....
    Try with this..

    Please Login or Register  to view this content.

  29. #29
    Forum Contributor stevebriz's Avatar
    Join Date
    09-07-2006
    Location
    Santiago Chile
    Posts
    389
    See attached
    Attached Files Attached Files

  30. #30
    Registered User
    Join Date
    05-16-2008
    Posts
    31
    Thanks, I'll see what happens.

  31. #31
    Registered User
    Join Date
    05-16-2008
    Posts
    31

    Smile

    Steve,
    You are truly a saint.

    Now I have only final question. Instead of me having to populate the Project_Pipeline H, I, J, K, with the name, if I run "Project_Pipeline" like this.
    H1 Consumer Business Employee National Sales Support
    H2 Yes No No Yes
    H3 No Yes Yes No
    H4 Yes No No Yes
    H5 No Yes Yes Yes

    What would the code be to Replace the Yes with the Column Name in H1 and delete the No out of the Cell?

    And again, you are a master.

  32. #32
    Forum Contributor stevebriz's Avatar
    Join Date
    09-07-2006
    Location
    Santiago Chile
    Posts
    389
    Ok but changing this will screw up the previous code.
    Here is another thought.
    why not just create a dropdown for all the cells and then you can select from drop down Consumer Business Employee National Sales Support in Columns H-K?

  33. #33
    Registered User
    Join Date
    05-16-2008
    Posts
    31
    But Can I run that code first on the Project_Pipeline then Run the other one? Just trying to limit manual processes as much as possible.
    So I would in Essences have 2 modules.

  34. #34
    Forum Contributor stevebriz's Avatar
    Join Date
    09-07-2006
    Location
    Santiago Chile
    Posts
    389
    ok this can be done.

    something like this should do it.

    Please Login or Register  to view this content.
    Note: If you are going to have headers in row 1 of you pipline sheet then you need to change the highlighted value in the previous sub I sent you from 1 to 2


    Please Login or Register  to view this content.

  35. #35
    Registered User
    Join Date
    05-16-2008
    Posts
    31

    Question

    Steve,
    Don't know, but that didn't work.
    Maybe I did something wrong or wasn't clear.
    If Project_Pipeline H2, etc = Yes, then replace Yes, with H1 Heading name and if Project_Pipeline H2, etc = No, then Delete No from the Cell?
    Is that possible?

  36. #36
    Forum Contributor stevebriz's Avatar
    Join Date
    09-07-2006
    Location
    Santiago Chile
    Posts
    389
    Sorry I had it working in the revers direction.

    try this one

    Please Login or Register  to view this content.

  37. #37
    Registered User
    Join Date
    05-16-2008
    Posts
    31
    Thanks Steve.
    We got the Date Down.

    Now on to my next question.
    If the Project Pipe Line H, I, J, K, L Matches the Value in Column C on Day View, and the Date in Row 14, I need to fill the data down Column C.

    So we are adding another variable in. The Dates have to Match and the LOB.
    Any suggestions?
    Attached Files Attached Files

  38. #38
    Registered User
    Join Date
    05-16-2008
    Posts
    31
    Any ideas?

  39. #39
    Registered User
    Join Date
    05-16-2008
    Posts
    31
    Steve,
    Any thoughts on how to accomplish this?

  40. #40
    Forum Contributor stevebriz's Avatar
    Join Date
    09-07-2006
    Location
    Santiago Chile
    Posts
    389
    Sorry I completely confused.
    This is what it did before you you commented out some of the stuff and made some other changes.

    Please see the attached and run this and you should see it works.
    The only change from the original is the extension of th categories of H-K to H-L.
    Please paste the macro from this sample book into your workbook and trash the old one as you have introduced some bugs into the old one.
    HTH
    Steve
    Attached Files Attached Files

  41. #41
    Registered User
    Join Date
    05-16-2008
    Posts
    31
    Me too! LOL.
    What I what to accomplish is this.
    With the current, we compare the Dates and paste the data from project pipeline.

    What I am wanting is to compare the Dates and the LOBs.
    For example. on the Day View, I have in Row 15, Column C "Consumer". I want to run it where it looks at Row 14 Date on Day View and if = project pipeline date Column "D" = and either pipeline column H, I, J, K, L = Row 15, Column C "Consumer" etc, then paste the Project PL C into the date on Row 14 Date on Day View. So in essence, we are comparing two variables Dates= between the two worksheets and the LOBs = then paste the info.
    If it all possible I would like to run it through all of the Day View Column C comparing it to all of pipeline H, I, J, K, L etc.
    I have included the updated wb.

  42. #42
    Registered User
    Join Date
    05-16-2008
    Posts
    31
    Ok, the wb didn't upload. Here it is.
    Attached Files Attached Files

  43. #43
    Forum Contributor stevebriz's Avatar
    Join Date
    09-07-2006
    Location
    Santiago Chile
    Posts
    389

    Wink

    This is what really it is doing ..l will explain below
    But firstly...as I understand it from you description what you want now will create something circular to what you already have and quite frankly doesn't make sense...as it will not provide you any more than the macro is already giving. In fact using Dayview Col C as you have it now it the " the selection criteria" to search the pipeline sheet will cause lots of issues...
    as
    a) you don't know from the Dayview what link is betwee "LOB" date and person is.
    b) you don't know the number rows need for each "LOB" in the dayview
    c) etc.

    Defining the problem
    Remember your source data is the project_pipeline sheet.
    1/ you have series of dates that you want to bring corresponding data across.
    2/ For each instance of the date and the "LOB" (Cols H-L) in the pipeline sheet you want a create a new row in the dayview.
    You populate the new row in the dayview with the name in the correct date column and the "LOB" in LOB column.(col C)


    Explanation of how the macro works
    For each Date in Dayview Row 14 it is looking in the PRJ_PL sheet for matching dates.
    If it finds a matching date then it looks at whether in Col H-L if there is a entry.
    If there is an entry if creates new row in the Dayview with the Name from PRJ_PL Col C and puts it in the matching date column. and adds the "LOB" eg."Consumer" to Dayview Col C.
    For Example.
    starting with 10-04-2008 ( Dayview Col D Rw 14)

    It will find the first entry 9534
    It will firstly create a row with "BOB" in col D and "Consumer" In dayview Col C
    Then it will create a row with "Bob" in Col D and "National Sales Support in Dayview Col C
    Then it will create a row with "Bob" in Col D and "Phone" in Dayview Col C
    After this it will look for the next match of the date 10-04-2008
    If no other matches for this date ( 10-04-2008 are found it moves to the next date ( Dayview Col E RW14).... and continues as before.

    SORTING/FILTERING to Group by LOB
    So If you want to see the dayview sheet by sorted by LOB
    the you can sort the rows by "LOB"
    alternatively use and autofilter
    ...eg..Consumer then use an auto filter From C14 down to the last row. c65336
    Then just click on C14 and select the "LOB" you want "Consumer"

    Steve

  44. #44
    Forum Contributor stevebriz's Avatar
    Join Date
    09-07-2006
    Location
    Santiago Chile
    Posts
    389
    Understand? Are you ok with it now?

  45. #45
    Registered User
    Join Date
    05-16-2008
    Posts
    31
    Yes, thanks. I will be back with new posts for NOOB VBA questions.

+ 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