?
Solved

Using an Index number to generate a table in excel?

Posted on 2011-03-22
5
Medium Priority
?
391 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
[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
  • 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 2000 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

762 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