Solved

Macro to populate unique values into table

Posted on 2013-02-01
10
315 Views
Last Modified: 2013-02-08
Hi Experts (All worksheets same workbook)

Need a macro the well run after the data selection has been made from validation list on cell d18, worksheet "ABC"

Click macro button then >

Populate results into table below same worksheet:-
Data table on worksheet "ABC" d22:d42

The result are pull back from worksheet "data" so look in column z which corresponds to the selection made from the data validation list cell d18 worksheet "ABC"
 And return the results back from Column AB....which goes into range D22:42 in above table and values are text...

Here the tricky bit only unique values...
0
Comment
Question by:route217
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 4
10 Comments
 
LVL 43

Expert Comment

by:Saqib Husain, Syed
ID: 38843743
Can you upload a small sample excel file?
0
 

Author Comment

by:route217
ID: 38843750
Apologies,  ssaqibh

Unable to do to restriction .... Sorry
0
 
LVL 43

Expert Comment

by:Saqib Husain, Syed
ID: 38843758
Not even a fake sample to help understanding?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:route217
ID: 38843765
Probably later on when I get home...
0
 

Author Comment

by:route217
ID: 38843825
Ssaqibh

Can work on something with our a workbook
0
 
LVL 43

Expert Comment

by:Saqib Husain, Syed
ID: 38844356
I would have liked to try but I am struggling to understand the description.
0
 

Author Comment

by:route217
ID: 38844516
ssaqibh

see attached workbook....with example in the worksheet - refer to txt...

I hope this helps..
Sample-Data.xls
0
 
LVL 43

Accepted Solution

by:
Saqib Husain, Syed earned 500 total points
ID: 38845945
Dim dat As Worksheet, nitems As Long, trow As Integer, cel As Range, i As Long
    Set dat = Sheets("Data")
    nitems = WorksheetFunction.CountIf(dat.Range("Z:Z"), ActiveSheet.Range("D18"))
    trow = ActiveSheet.Range("D:D").Find("Total", , , xlWhole).Row
    If trow < 22 + nitems Then
        Cells(trow, 4).Resize(22 + nitems - trow).EntireRow.Insert
    ElseIf trow > 22 + nitems Then
        Cells(22 + nitems, 4).Resize(trow - 22 - nitems).EntireRow.Delete
    End If
    Cells(22, 4).Resize(nitems).ClearContents
    trow = 22 + nitems
    Cells(21, 4) = " "
    For Each cel In dat.Range("Z1:Z" & dat.Range("Z" & Rows.Count).End(xlUp).Row)
        If cel = ActiveSheet.Range("D18") Then
            ActiveSheet.Cells(trow, 4).End(xlUp).Offset(1) = cel.Offset(, 2)
        End If
    Next cel
        Cells(21, 4).ClearContents
    For i = trow - 1 To 23 Step -1
        If Not ActiveSheet.Range("D22:D" & i - 1).Find(ActiveSheet.Cells(i, 4), , , xlWhole) Is Nothing Then
        ActiveSheet.Cells(i, 4).EntireRow.Delete
    End If
    Next i
0
 

Author Comment

by:route217
ID: 38846336
Thanks ssaqibh

Let me test the code...
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question