Solved

Using an Index number to generate a table in excel?

Posted on 2011-03-22
5
357 Views
Last Modified: 2013-11-27
I have a combo box (combo box 1) which is currently linked to cell A1 in a given sheet.

A1 is showing an index number that changes when the value of the combo box changes.

I have another sheet in the same workbook that has a table using this index.

it has 1000's of rows and x number of columns.

I'd like to show a table of each row that has this index on the same sheet that has the combo box.

0
Comment
Question by:sanjangeorge
  • 3
5 Comments
 
LVL 30

Expert Comment

by:SiddharthRout
ID: 35193312
May I see a sample file so that I can get my references correct?

Sid
0
 

Author Comment

by:sanjangeorge
ID: 35193378
Here you go Sid
ExampleForTables.xls
0
 
LVL 4

Expert Comment

by:MeLindaJohnson
ID: 35193526
Could you do this as a pivot table?
0
 
LVL 30

Expert Comment

by:SiddharthRout
ID: 35193527
The code is almost ready. Quick question. Will there be duplicates values in Sheet1?

Sid
0
 
LVL 30

Accepted Solution

by:
SiddharthRout earned 500 total points
ID: 35193582
If there won't be duplicate values then try this :)

Sample File Attached. All you need to do is manually change the values in Cell A1

Sid

Code Used

Private Sub Worksheet_Change(ByVal Target As Range)
    Application.EnableEvents = False
    If Not Intersect(Target, Range("A1")) Is Nothing Then
        Dim ws1 As Worksheet, ws2 As Worksheet
        Dim i As Long, ws1LastRow As Long, ws2LastRow As Long
        Dim matchIndex As String, AllCars As String
        
        On Error GoTo Whoa
        
        Set ws1 = ActiveSheet
        Set ws2 = Sheets("Sheet1")
        ws2LastRow = ws2.Range("A" & Rows.Count).End(xlUp).Row
        
        ws1.Range("A12:E" & Rows.Count).ClearContents
        
        matchIndex = Target.Value
        
        With ws2
            .Range("$A$1:$E$" & ws2LastRow).AutoFilter Field:=1, Criteria1:=matchIndex
            .UsedRange.Offset(1, 0).Resize(.UsedRange.Rows.Count - 1).Rows.Copy _
            ws1.Range("A12")
            .Range("$A$1:$E$" & ws2LastRow).AutoFilter
        End With
        
        ws1LastRow = ws1.Range("B" & Rows.Count).End(xlUp).Row
        
        For i = 12 To ws1LastRow
            AllCars = AllCars & ", " & ws1.Range("C" & i).Value
        Next i
        
        ws1.Range("G3").Value = Mid(AllCars, 2)
    End If
LetsContinue:
    Application.EnableEvents = True
    Exit Sub
Whoa:
    MsgBox Err.Description
    Resume LetsContinue
End Sub

Open in new window

Index-Numbers.xls
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Suggested Solutions

I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
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 Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

910 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

22 Experts available now in Live!

Get 1:1 Help Now