+ Reply to Thread
Results 1 to 2 of 2

Loop, copy, count

  1. #1
    Registered User
    Join Date
    03-31-2014
    Location
    Germany
    MS-Off Ver
    Excel 2003
    Posts
    48

    Loop, copy, count

    Hi,
    I have following Problem, I managed this, but just wondering, there has to be a "charm" solution for that

    My data looks as follows:

    In the 1st Column there is a text like "Scope", 2nd column Description, 4 column Dates.
    Now, I wanted to to Count distinct values like "concatenate Scope+Description+01.03.2017+Date then Scope+Desription+Target1+03.03.2017.....Scope+Target2+Description+Date
    If it reaches Scope1 then the same calculation, but for Scope1, and then for Scope2 = Scope is like "Header" for each area

    vba.PNG

    Now I did it like this, FirstRow is 8, I check if contains "Scope" then for each copy into Column 4

    Please Login or Register  to view this content.
    Then I copy this "Scope" below until it reaches "Scope1" and so on...The same I am doing with Targets. After that I concatenate the 3 Values and calculate dinstic values
    Please Login or Register  to view this content.
    Thank you very much

    pls see the screenshot
    test4.PNG

    hi,
    please see attached, this is of course not the whole sheet, but an example, the code is also not completed, I just Need this beginning...
    Attached Files Attached Files
    Last edited by JBeaucaire; 03-24-2017 at 09:09 AM.

  2. #2
    Forum Expert
    Join Date
    05-20-2015
    Location
    Chicago, Illinois
    MS-Off Ver
    2016
    Posts
    2,103

    Re: Loop, copy, count

    If I'm understanding your request correctly, I think you can achieve the results you want without VBA. In the 'Formula Solution' sheet of my attachment, I've used the following formulas:

    In A4: =IF(OR(ISNUMBER(SEARCH("Scope",Source!A4)),Source!C4>0),IF(TRIM(Source!A4)="",A3,Source!A4),"")

    In C4: =IF(Source!C4>0,Source!C4,"")

    In D4, array-entered (Confirmed with Ctrl + Shift + Enter instead of Enter: =IF($C4="","",INDEX($A$4:$A4,MAX(IF(ISNUMBER(SEARCH("Scope",$A$4:$A4)),ROW($A$4:$A4)))-3))

    In E4: =IF(Source!E4<>"",Source!E4,"")

    Fill all of these formulas down 50 or so rows (or however many you think you'll need). The result is a table that will automatically update as you add or change data on 'Paste'. I've also added totals columns using the following in G5, array entered and filled down:

    =IFERROR(INDEX($D$4:$D$50,MATCH(0,IF($D$4:$D$50="",1,COUNTIF($G$4:$G4,$D$4:$D$50)),0)),"")

    And in H5, filled right and down (non-array): =IF($G5="","",COUNTIFS($D$4:$D$50,$G5,$E$4:$E$50,H$3))

    It's a lot to enter, but it should provide a automatically updating "results" page without requiring VBA. Take a look at the attachment to see if it will work for you:
    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. [SOLVED] Loop through a userform listbox & copy certain columns into txtboxes on userform loop next
    By mtilbury in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-31-2016, 10:10 AM
  2. [SOLVED] Loop until cell values match then copy, move to next cell and loop and copy again
    By potga in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-11-2016, 08:51 PM
  3. VBA Loop, Find, Copy, Repeat Loop
    By sparx in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-02-2013, 06:25 AM
  4. [SOLVED] Destination copy and paste (values only) for copy loop
    By mr_mango81 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-01-2013, 08:59 PM
  5. [SOLVED] Copy dynamically changing column and Paste using VBA Loop (Loop within Loop)
    By nixon72 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-12-2013, 12:46 PM
  6. [SOLVED] VBA loop to copy a worksheet a number of times, assign name each time based on loop number
    By TBG in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-29-2012, 10:54 PM
  7. [SOLVED] Loop-copy cell values from a row, and then copy them into a column
    By vukovicnikola in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-15-2012, 06:03 AM

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