I have tried to use several workarounds and other posts, but cannot seem to find a way to answer the error I am having.
I am using Excel 2013 and am trying to grab information from a table to consolidate it. I could not get the range to work so I eventually added in the three lines before "'Add in consolidate here to set up chart data". I was hoping to be able to copy the table data somewhere else and that this would make it easier to consolidate. However, I am still having the same error above with the information that I copied to T1.
Ideally, I would like to remove those three rows of code and find a way to grab the filtered table information and consolidate it. The reason it needs to be consolidated is that it will have multiple values for state in the table and I need to see the sum of a few categories based off of state (and other variables).
If I have to copy the data to another location (like the code is currently), then that is fine as well. Please help me figure out why the code keeps on breaking at the consolidate piece of the code.
I am using Excel 2013 and am trying to grab information from a table to consolidate it. I could not get the range to work so I eventually added in the three lines before "'Add in consolidate here to set up chart data". I was hoping to be able to copy the table data somewhere else and that this would make it easier to consolidate. However, I am still having the same error above with the information that I copied to T1.
Ideally, I would like to remove those three rows of code and find a way to grab the filtered table information and consolidate it. The reason it needs to be consolidated is that it will have multiple values for state in the table and I need to see the sum of a few categories based off of state (and other variables).
If I have to copy the data to another location (like the code is currently), then that is fine as well. Please help me figure out why the code keeps on breaking at the consolidate piece of the code.
Code:
Private Sub ComboBox2_Change()
Dim Issuer As String
Dim FirstRow As Long
Dim LastRow As Long
Dim LastCol As Long
Dim ws1 As Worksheet
Dim ws2 As Worksheet
Dim wkbk As Workbook
Dim MyArray As Variant
Set wkbk = ActiveWorkbook
Set ws1 = Worksheets("Data")
Set ws2 = Worksheets("ChartData")
Issuer = ws2.Range("IssuerNum").Value
If Issuer = "All" Then
Worksheets("Data").ListObjects("Table1").Range.AutoFilter _
Field:=1, Criteria1:="<>", Operator:=xlFilterValues
LastRow = ws1.Cells(ws1.Rows.Count, "A").End(xlUp).Row
FirstRow = ws1.Cells(2, 1).Row
Else
ws1.ListObjects("Table1").Range.AutoFilter _
Field:=1, Criteria1:=Issuer, Operator:=xlFilterValues
With ws1.ListObjects("Table1").AutoFilter.Range.SpecialCells(xlCellTypeVisible)
LastRow = .Areas(.Areas.Count).Row + .Areas(.Areas.Count).Rows.Count - 1
End With
FirstRow = ws1.ListObjects("Table1").AutoFilter.Range.Offset(1).SpecialCells(xlCellTypeVisible).Cells(1, 2).Row
End If
ws1.Range(ws1.Cells(FirstRow, 3), ws1.Cells(LastRow, 9)).Copy Destination:=ws2.Range("T1")
LastRow = ActiveSheet.Cells(ActiveSheet.Rows.Count, "T").End(xlUp).Row
LastCol = ActiveSheet.Range("T1").SpecialCells(xlCellTypeLastCell).Column
'Add in consolidate here to set up chart data
If ws2.Range("RadioSel").Value = 1 Then
ws2.Range("A2").Consolidate _
Sources:=ws2.Range(ws2.Cells(1, 20), ws2.Cells(LastRow, 26)), _
Function:=xlSum, LeftColumn:=True