+ Reply to Thread
Results 1 to 16 of 16

Appling a range of data to a range of individual cells

Hybrid View

  1. #1
    Registered User
    Join Date
    05-06-2013
    Location
    Cape Town
    MS-Off Ver
    Excel 2007
    Posts
    16

    Appling a range of data to a range of individual cells

    HI,

    I am trying populate a range of products to a range of customers so that the whole range of products can be applied to each customer.

    In the files below I have a selection of the customers and products. I want to combine the two so that it looks like tab 7

    combined.jpgproducts.jpgcustomers.jpg

    Your help would be appreciated.

  2. #2
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Appling a range of data to a range of individual cells

    Instead of screenshots, please attach a sample workbook with expected output for better understanding


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  3. #3
    Registered User
    Join Date
    05-06-2013
    Location
    Cape Town
    MS-Off Ver
    Excel 2007
    Posts
    16

    Re: Appling a range of data to a range of individual cells

    Sample workbook..xlsx

    Hi Sixthsense,

    Please see the workbook attached. I did it manually for this example, but there are over 900 customers.

  4. #4
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Appling a range of data to a range of individual cells

    Try this code...

    Sub AddProductsToCustomers()
    Dim rCust As Range, rProd As Range, rMyRng As Range, nEndRw As Long
    
    Application.ScreenUpdating = False
    
    Set rCust = Sheets("Customers").Range("A1").CurrentRegion
    Set rProd = Sheets("Products").Range("A1").CurrentRegion
    nEndRw = rCust.Rows.Count
    
    Sheets.Add
    ActiveSheet.Name = "Output " & Sheets.Count
    Set rMyRng = Cells(1, "A")
    
    For i = 1 To nEndRw
        Set rMyRng = rMyRng.Resize(rProd.Rows.Count)
            rMyRng.Value = rCust.Cells(i).Value
            rProd.Copy rMyRng.Cells(1).Offset(0, 1)
        Set rMyRng = rMyRng.Offset(rMyRng.Rows.Count)
    Next i
    
    Range("A1").CurrentRegion.Columns.AutoFit
    
    Application.ScreenUpdating = True
    
    End Sub

  5. #5
    Registered User
    Join Date
    05-06-2013
    Location
    Cape Town
    MS-Off Ver
    Excel 2007
    Posts
    16

    Re: Appling a range of data to a range of individual cells

    Thanks, however I'm not that advanced a user to know what to do with this code. Is there a simpler way, or can you explain?

  6. #6
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Appling a range of data to a range of individual cells

    I have attached your sample file with Macro Code for your reference.

    Refer the below link to know how to insert VBA code in Module
    http://www.contextures.com/xlvba01.html
    Attached Files Attached Files

  7. #7
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Appling a range of data to a range of individual cells

    Insert a new column in Column-C

    In C2 Cell
    =IF(AND(COUNTIFS($A$2:A2,A2,$B$2:B2,B2)>1,F2=0),"Select&Delete","RequiredData")
    Drag it down...

    Copy and paste the column-C formula as values using paste special.

    Now Apply filter for column-C and select "Select&Delete" and delete the entire row...

  8. #8
    Registered User
    Join Date
    06-29-2011
    Location
    MUMBAI
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    85

    Re: Appling a range of data to a range of individual cells

    This can be done with a macro

  9. #9
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Appling a range of data to a range of individual cells

    Try this in Duplicate file.

    Select Column-A & Column-B and Data>>Remove Duplicates>>Ok...

  10. #10
    Registered User
    Join Date
    05-06-2013
    Location
    Cape Town
    MS-Off Ver
    Excel 2007
    Posts
    16

    Re: Appling a range of data to a range of individual cells

    Tried that before, it removes the duplicates in those two columns, however it does not remove the remaining information in each line along with the duplicates. All that happens is that Column A&B shortens and mis-aligns the data to the right.

  11. #11
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Appling a range of data to a range of individual cells

    Oopss... Just select the whole range of data and in Remove duplicates Give Tick for Column-A & B alone which will do the task perfectly.

    Please check and confirm

  12. #12
    Registered User
    Join Date
    05-06-2013
    Location
    Cape Town
    MS-Off Ver
    Excel 2007
    Posts
    16

    Re: Appling a range of data to a range of individual cells

    Ha Ha, yes I've tried that too. If you look at the top of the sample, next to Annual total there is the number "274". That counts all the value in the Annual total column. As soon as you do it as you suggest above, the number drops to "257", meaning that it is deleting rows that have values in them, and I need that data to remain and the duplicates that are empty to be deleted instead.

  13. #13
    Registered User
    Join Date
    05-06-2013
    Location
    Cape Town
    MS-Off Ver
    Excel 2007
    Posts
    16

    Re: Appling a range of data to a range of individual cells

    I just get the words "ReduiredData" in each column

  14. #14
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Appling a range of data to a range of individual cells

    Refer the attached file for details
    Attached Files Attached Files

  15. #15
    Registered User
    Join Date
    05-06-2013
    Location
    Cape Town
    MS-Off Ver
    Excel 2007
    Posts
    16

    Re: Appling a range of data to a range of individual cells

    Thanks, found the problem. It was in the way I sorted the info. It is tracking now.

    Thank you very much for all your help. You're a legend!!!!

+ 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