CalRich1023
New Member
- Joined
- Mar 15, 2021
- Messages
- 48
- Office Version
- 365
- Platform
- Windows
- MacOS
Hello,
I have a search sheet to loop through my entire workbook and return results into a table-style format. for some reason it is producing 500 rows, but I only want it to produce enough rows for the data that is returned. I will paste the code below, and color the font of where the problem is occurring. The table data is from "A6:K6" and varying amount of rows (depending on search results. Table headers are in "A5:K5" I know I'm missing something small, but I just can't seem to find it. Thanks!
'FORMAT RESULTS AS A TABLE
'BUILD THE TABLE
Dim LastRow1 As Long
LastRow1 = Cells(Rows.Count, "A").End(xlUp).Row
ActiveWorkbook.Sheets("SEARCH").ListObjects.Add(xlSrcRange, Range("A5:K5" & LastRow1), , xlYes) _
.Name = "SEARCH_RESULTS_TABLE"
'COLOR THE TABLE GRAY/WHITE
ActiveWorkbook.Sheets("SEARCH").ListObjects("SEARCH_RESULTS_TABLE").TableStyle = "TableStyleMedium1"
'SHOWS TOTAL QUANTITY AT BOTTOM OF COLUMN "D"
ActiveWorkbook.Sheets("SEARCH").ListObjects("SEARCH_RESULTS_TABLE").ShowTotals = True
ActiveWorkbook.Sheets("SEARCH").ListObjects("SEARCH_RESULTS_TABLE").ListColumns(4) _
.TotalsCalculation = xlTotalsCalculationSum
I have a search sheet to loop through my entire workbook and return results into a table-style format. for some reason it is producing 500 rows, but I only want it to produce enough rows for the data that is returned. I will paste the code below, and color the font of where the problem is occurring. The table data is from "A6:K6" and varying amount of rows (depending on search results. Table headers are in "A5:K5" I know I'm missing something small, but I just can't seem to find it. Thanks!
'FORMAT RESULTS AS A TABLE
'BUILD THE TABLE
Dim LastRow1 As Long
LastRow1 = Cells(Rows.Count, "A").End(xlUp).Row
ActiveWorkbook.Sheets("SEARCH").ListObjects.Add(xlSrcRange, Range("A5:K5" & LastRow1), , xlYes) _
.Name = "SEARCH_RESULTS_TABLE"
'COLOR THE TABLE GRAY/WHITE
ActiveWorkbook.Sheets("SEARCH").ListObjects("SEARCH_RESULTS_TABLE").TableStyle = "TableStyleMedium1"
'SHOWS TOTAL QUANTITY AT BOTTOM OF COLUMN "D"
ActiveWorkbook.Sheets("SEARCH").ListObjects("SEARCH_RESULTS_TABLE").ShowTotals = True
ActiveWorkbook.Sheets("SEARCH").ListObjects("SEARCH_RESULTS_TABLE").ListColumns(4) _
.TotalsCalculation = xlTotalsCalculationSum