+ Reply to Thread
Results 1 to 5 of 5

return without duplication, data from several guides

Hybrid View

  1. #1
    Valued Forum Contributor marreco's Avatar
    Join Date
    07-02-2011
    Location
    Brazil
    MS-Off Ver
    Excel 2010
    Posts
    1,862

    return without duplication, data from several guides

    Hi.

    how to return without duplication, the data from each column "A" of all the different worksheet tab "analytical"
    data must be put on the "analytical" column "A"
    Attached Files Attached Files
    "No xadrez nem sempre a menor dist?ncia entre dois pontos ? uma linha reta" G. Kasparov.

    If your problem is solved, please say so clearly, and mark your thread as Solved: Click the Edit button on your first post in the thread, Click Go Advanced, select b from the Prefix dropdown, then click Save Changes. If more than two days have elapsed, the Edit button will not appear -- ask a moderator to mark it.

  2. #2
    Valued Forum Contributor
    Join Date
    08-13-2012
    Location
    Gardony, Hungary
    MS-Off Ver
    Excel 2003
    Posts
    558

    Re: return without duplication, data from several guides

    Hi marreco,

    please try this macro.
    Option Explicit
    
    ' props to JP
    ' http://www.jpsoftwaretech.com/finding-values-in-an-array-without-looping/
    Function IsInArray(arr As Variant, valueToFind As Variant) As Boolean
    ' checks if valueToFind is found in arr, no loop!
      IsInArray = (UBound(Filter(arr, valueToFind)) > -1)
    End Function
    
    Sub Test()
         
    Dim Sh As Worksheet
    
    Dim MyArray() As Variant
    Dim Lr As Long, a As Long, i As Long
    Dim isThere As Boolean
    
    ReDim MyArray(0)
    a = 0
    
    For Each Sh In ActiveWorkbook.Worksheets
        If Sh.Name <> "analytical" Then
            Lr = Sh.Range("A65536").End(xlUp).Row
            For i = 4 To Lr
                isThere = IsInArray(MyArray, Sh.Range("A" & i).Value)
                If isThere = False Then
                    ReDim Preserve MyArray(a)
                    MyArray(a) = Sh.Range("A" & i).Value
                    a = a + 1
                End If
            Next i
        End If
    Next Sh
    
    For i = 3 To a + 2
        Sheets("analytical").Range("A" & i) = MyArray(i - 3)
    Next i
    
    End Sub

  3. #3
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: return without duplication, data from several guides

    Hi Friend Marreco,

    Try this:

    Sub MarMos(): Dim ws As Worksheet, wa As Worksheet
    Dim Vlr As Single, R As Range, S As Range, c As Integer
    Set wa = Workbooks("ColumnAllSheets").Worksheets("analytical")
    For Each R In wa.Range("A3:A" & wa.Range("A1").End(xlDown).row)
    For Each ws In ActiveWorkbook.Worksheets
    If ws.Name = "RESUMO VENDAS" Then GoTo GetNextSheet
    If ws.Name = wa.Name Then GoTo GetNextSheet
    If ws.Range("A4") = "" Then GoTo GetNextSheet
    
    For Each S In ws.Range("A4:A" & ws.Range("A3").End(xlDown).row)
    If S = R Then Vlr = Vlr + ws.Range("B" & S.row)
    Next
    
    If Vlr Then
    c = 1: Do Until wa.Cells(2, c) = UCase(Left(ws.Name, 3)): c = c + 1: Loop
    wa.Cells(R.row, c) = Vlr: Vlr = 0: End If
    GetNextSheet: Next: Next: End Sub
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  4. #4
    Valued Forum Contributor marreco's Avatar
    Join Date
    07-02-2011
    Location
    Brazil
    MS-Off Ver
    Excel 2010
    Posts
    1,862

    Re: return without duplication, data from several guides

    Hi.
    I'm happy for the answers!!

    thank you very much!!

  5. #5
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: return without duplication, data from several guides

    You're welcome!

+ 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