+ Reply to Thread
Results 1 to 2 of 2

define multi region and sort it using unicity

  1. #1
    Maileen
    Guest

    define multi region and sort it using unicity

    Hi,

    I have an excel sheet on which I have more than 17000 records.
    these records consist of :

    column description
    A Software editor
    B Software Name
    C User
    D Computer number
    E Path where is the exe
    ....

    a user could save in several different folders the same software exe file.
    So i would like to create a region / selection based on the couple
    "Software editor + Software name" (which is normally unique) and to
    filter this region / selection using the column D (computer number) in
    order to avoid all multiple folder where could be saved the exefile...

    everything should be done, using VBA.

    for example :

    A B C D E
    MS Win XP test01 PC-0001 C:\Windows
    MS Visio 2000 test01 PC-0001 C:\Program files\Visio
    Gooly tetris test01 PC-0001 C:\Program files\gooly
    Gooly tetris test01 PC-0001 C:\backup\gooly

    MS Win XP test02 PC-0001 C:\Windows
    Gooly tetris test01 PC-0002 C:\Program files\gooly

    so when i click on my inventory button, i launch the VBA macro and for
    the editor Gooly, Game Tetris, macro should return me 2 an not 3 because
    i should filter my selection/region, using PC number (so i don't care
    how many time the exe file is available on 1 PC...

    thanks a lot,
    Maileen


  2. #2
    Forum Contributor
    Join Date
    11-29-2003
    Posts
    1,203
    Try this (assumes that there are headers in row 1):

    Sub test()
    '
    'clear any old data
    Columns("F:Z").ClearContents

    'find the last row
    LastRow = Range("A1").End(xlDown).Row

    'create list of Editor & Name
    Range("F1").FormulaR1C1 = "=+RC1&"" - "" &RC2"
    Range("F1:F" & LastRow).FillDown

    'create list of Editor & Name & PC
    Range("G1").FormulaR1C1 = "=+RC1&RC2&RC4"
    Range("G1:G" & LastRow).FillDown

    'replace formulas with values
    Range("F1:G" & LastRow).Select
    Selection.Copy
    Selection.PasteSpecial Paste:=xlPasteValues
    Application.CutCopyMode = False

    'create unique list of Editor & Name
    Range("F1:F" & LastRow).AdvancedFilter _
    Action:=xlFilterCopy, CopyToRange:=Range("J1"), Unique:=True

    'filter for unique list of Editor & Name & PC
    Range("G1:G" & LastRow).AdvancedFilter _
    Action:=xlFilterInPlace, Unique:=True

    'copy list of Editor & Name that has been filtered for PC
    Range("F1:F" & LastRow).Copy Destination:=Range("I1")
    Application.CutCopyMode = False

    'remove filter
    ActiveSheet.ShowAllData

    'find last row of Editor & Name
    LastRow = Range("J1").End(xlDown).Row

    'count the occurances of each Editor & Name
    Range("K2").FormulaR1C1 = "=COUNTIF(C9,RC10)"
    Range("K2:K" & LastRow).FillDown

    'replace formulas with values
    Range("K2:K" & LastRow).Select
    Selection.Copy
    Selection.PasteSpecial Paste:=xlPasteValues
    Application.CutCopyMode = False

    'clear temporary lists
    Columns("F:I").ClearContents

    End Sub

+ 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