Solved

Macro to populate unique values into table

Posted on 2013-02-01
10
306 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
  • 6
  • 4
10 Comments
 
LVL 43

Expert Comment

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

Author Comment

by:route217
Comment Utility
Apologies,  ssaqibh

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

Expert Comment

by:Saqib Husain, Syed
Comment Utility
Not even a fake sample to help understanding?
0
 

Author Comment

by:route217
Comment Utility
Probably later on when I get home...
0
 

Author Comment

by:route217
Comment Utility
Ssaqibh

Can work on something with our a workbook
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 43

Expert Comment

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

Author Comment

by:route217
Comment Utility
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
Comment Utility
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
Comment Utility
Thanks ssaqibh

Let me test the code...
0
 

Author Comment

by:route217
Comment Utility
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now