Macro that subtotals and formats refreshed Power Query data.

jamiemarie

Board Regular
Joined
Jun 24, 2020
Messages
67
Office Version
  1. 365
Platform
  1. Windows
Hi all. Before I begin, I'd just like to say thanks for all the help I've received in the past couple weeks, ya'll are amazing for volunteering to help so many people!

Here's my problem:
I have a fabric inventory table that I refresh through Power Query. I then change the table to a range to subtotal and format so taking inventory is easier. I recorded a macro to help with this, I will leave the code below. The macro subtotals the Bin Location Column and puts the count in the Batch Column, then the formatting starts. It turns all the Count rows dark green, makes the Batch column bold, then finds and replaces the word Count with a space so there is no word there.
The problem comes when I refresh the table, if I have more Bins than when I originally recorded the macro, It won't change the new Bin Locations to the dark green color and doesn't bold the count in the batch column. Can someone please help with my macro to have it do this? Information below.

Bin LocationBatch AX CountSE2 CountItem IdItem Name
MS13001B4823922F-1615PERFORMANCE YARN DYED LINEN WEAVE, INDIGO
MS13001B4823954.24F-1615PERFORMANCE YARN DYED LINEN WEAVE, INDIGO
MS13001B48264315F-1615PERFORMANCE YARN DYED LINEN WEAVE, INDIGO
MS13001B5963515F-1616PERFORMANCE YARN DYED LINEN WEAVE, SHELTER BLUE
MS13001B62054445F-1619PERFORMANCE TWILL, GRANITE
MS13001B62026420F-1621PERFORMANCE TWILL, TEAL
MS13001B6140623F-1812PERFORMANCE YARN DYED LINEN WEAVE, FRENCH BLUE
MS13001C6013472F-1620PERFORMANCE TWILL, STONE
MS13001C5771905.99F-1622PERFORMANCE BASKET SLUB, DARK HORSERADISH
MS13001C5597612.15F-1624PERFORMANCE BASKET SLUB, MIDNIGHT
MS13001C6268413.13F-1698PERFORMANCE BASKET SLUB, PEWTER GREY
MS13001C6288843.93F-1732PERFORMANCE COASTAL LINEN, PEBBLE STONE
MS13001C58478445F-1791PERFORMANCE COASTAL LINEN, OATMEAL
MS13001C5859093F-1791PERFORMANCE COASTAL LINEN, OATMEAL
MS13001D5977726.28F-0978PERFORMANCE BASKETWEAVE, NATURAL
MS13001D4155383F-0979PERFORMANCE BASKETWEAVE, METAL
MS13001D60347712.9F-0979PERFORMANCE BASKETWEAVE, METAL
MS13001D6272513F-1614PERFORMANCE YARN DYED LINEN WEAVE, FROST GREY
MS13001D62725653.4F-1614PERFORMANCE YARN DYED LINEN WEAVE, FROST GREY
MS13001D4960762F-1625PERFORMANCE EVERYDAY VELVET, INK BLUE
MS13001D5044392F-1625PERFORMANCE EVERYDAY VELVET, INK BLUE
MS13002A6344092F-0978PERFORMANCE BASKETWEAVE, NATURAL
MS13002A63441056.1F-0978PERFORMANCE BASKETWEAVE, NATURAL
MS13002A63441156F-0978PERFORMANCE BASKETWEAVE, NATURAL
MS13002A63441261.1F-0978PERFORMANCE BASKETWEAVE, NATURAL
MS13002A63441330F-0978PERFORMANCE BASKETWEAVE, NATURAL
MS13002B3760763F-0873YARN DYED LINEN WEAVE, INDIGO
MS13002B63438916.88F-1027YARN DYED LINEN WEAVE, STONE WHITE
MS13002B58292720F-1795YARN DYED LINEN WEAVE, STEEL GREY
MS13002B5877100.69F-1796YARN DYED LINEN WEAVE, NATURAL
MS13002C35873330F-0426LINEN WEAVE, NATURAL
MS13002C32457710F-0920BASKETWEAVE SLUB, ASH
MS13002D6021911F-0425PEBBLE WEAVE, OATMEAL
MS13002D6280733.31F-0477PEBBLE WEAVE, AEGEAN BLUE
MS13002D32189715F-0905WORN VELVET, METAL
MS13003B6279861F-0989BASKET SLUB, FEATHER GREY
MS13003B6018132F-1114BASKET SLUB, DARK HORSERADISH
MS13003B5829541F-1592BASKET SLUB, BLUE STONE
MS13003B5902273.21F-1594BASKET SLUB, DESERT SUNSET
MS13003C6175053F-0398MARLED MICROFIBER, HEATHER GREY
MS13003C5625548F-1598CHUNKY BASKETWEAVE, CHARCOAL
MS13003C5650098F-1599CHUNKY BASKETWEAVE, METAL
MS13003C59020230.68F-1599CHUNKY BASKETWEAVE, METAL
MS13003C5169863F-1600CHUNKY BASKETWEAVE, SLATE
MS13003D331924F-0398MARLED MICROFIBER, HEATHER GREY
MS13003D6180208F-0398MARLED MICROFIBER, HEATHER GREY
MS13003D13465258.53F-0621MARLED MICROFIBER, ASH GREY
MS13003D13477853.61F-0621MARLED MICROFIBER, ASH GREY
MS13003D13477953.61F-0621MARLED MICROFIBER, ASH GREY
MS13003D13478057.99F-0621MARLED MICROFIBER, ASH GREY
MS13003D1347811.99F-0621MARLED MICROFIBER, ASH GREY
MS13003D1347826.26F-0621MARLED MICROFIBER, ASH GREY
MS13003D13478318F-0621MARLED MICROFIBER, ASH GREY
MS13003D1395842F-0621MARLED MICROFIBER, ASH GREY
MS13003D61419345.95F-0621MARLED MICROFIBER, ASH GREY
MS13004C63948045.95F-0227PERF VELVET, DOVE GREY
MS13004C63751113.57F-0359PERF VELVET, STONE
MS13004C64165920.79F-0359PERF VELVET, STONE
MS13004C3255412F-0445PERF VELVET, MOSS
MS13004C63958112.54F-0445PERF VELVET, MOSS
MS13004C63958947.05F-0445PERF VELVET, MOSS
MS13004C63959012.26F-0445PERF VELVET, MOSS
MS13004D6380445F-0227PERF VELVET, DOVE GREY
MS13004D6394813.64F-0227PERF VELVET, DOVE GREY
MS13005B2372838F-0357PERF VELVET, LAGOON
MS13005B5902583.84F-0357PERF VELVET, LAGOON
MS13005B63937510F-0357PERF VELVET, LAGOON
MS13005B63941622.02F-0357PERF VELVET, LAGOON
MS13005B63942112F-0357PERF VELVET, LAGOON
MS13005D6024752.94F-0230PERF VELVET, OTTER
MS13006B3900791F-1034DISTRESSED VELVET, LIGHT TAUPE
MS13006B63763130F-1034DISTRESSED VELVET, LIGHT TAUPE
MS13006C6017325F-1060DISTRESSED VELVET, PEACOCK
MS13006C3977240.77F-1062DISTRESSED VELVET, FOREST
MS13006C5988822F-1063DISTRESSED VELVET, OLIVE
MS13006C6105524F-1063DISTRESSED VELVET, OLIVE
MS13006C6105558F-1063DISTRESSED VELVET, OLIVE
MS13006C6140851.63F-1113DISTRESSED VELVET, RUST
MS13006D3974861F-1059DISTRESSED VELVET, MINERAL GREY
MS13006D6351672.14F-1059DISTRESSED VELVET, MINERAL GREY
MS13006D6394927.5F-1059DISTRESSED VELVET, MINERAL GREY
MS13006D63949430F-1059DISTRESSED VELVET, MINERAL GREY
MS13007B13540644.5F-0675CHENILLE TWEED, FROST GRAY
MS13007B13540744.4F-0675CHENILLE TWEED, FROST GRAY
MS13007B3947655F-0675CHENILLE TWEED, FROST GRAY
MS13007B61736343.5F-0675CHENILLE TWEED, FROST GRAY
MS13007B6173702.15F-0675CHENILLE TWEED, FROST GRAY
MS13007B5791423F-0676CHENILLE TWEED, NIGHTSHADE
MS13007B6114422.55F-0676CHENILLE TWEED, NIGHTSHADE
MS13007B62500228.32F-0676CHENILLE TWEED, NIGHTSHADE
MS13007B61355212F-1693CHENILLE TWEED, IRONGATE
MS13007B6343977.2F-1693CHENILLE TWEED, IRONGATE
MS13007B63440516F-1693CHENILLE TWEED, IRONGATE
MS13007B6344069.86F-1693CHENILLE TWEED, IRONGATE
MS13007C6172204.75F-0673CHENILLE TWEED, SLATE
MS13007C63636912.08F-0673CHENILLE TWEED, SLATE
MS13007C28574610F-0674CHENILLE TWEED, FEATHER GREY
MS13007C5843808F-1699CHENILLE TWEED,PEWTER
MS13007C60291743.5F-1699CHENILLE TWEED,PEWTER
MS13007C6075403F-1699CHENILLE TWEED,PEWTER
MS13007C60754319.73F-1699CHENILLE TWEED,PEWTER
MS13007D13544246.2F-0674CHENILLE TWEED, FEATHER GREY
MS13007D13544344.5F-0674CHENILLE TWEED, FEATHER GREY
MS13007D13545343.1F-0674CHENILLE TWEED, FEATHER GREY
MS13007D13545444.1F-0674CHENILLE TWEED, FEATHER GREY
MS13007D13545542.9F-0674CHENILLE TWEED, FEATHER GREY
MS13007D13545744.7F-0674CHENILLE TWEED, FEATHER GREY
MS13007D13545944.5F-0674CHENILLE TWEED, FEATHER GREY
MS13007D13546044.7F-0674CHENILLE TWEED, FEATHER GREY
MS13007D13546244.6F-0674CHENILLE TWEED, FEATHER GREY
MS13007D4003483.37F-0674CHENILLE TWEED, FEATHER GREY
MS13008A24779047.6F-0821WE-TWILL, STONE
MS13008B2477913F-0821WE-TWILL, STONE
MS13008B24528552.2F-0822WE-TWILL, GRAVEL
MS13008B3658751F-0822WE-TWILL, GRAVEL
MS13008B60853337.29F-0822WE-TWILL, GRAVEL
MS13008B6396073.71F-0897WE-TWILL, WHEAT
MS13008B63960812.54F-0897WE-TWILL, WHEAT
MS13008B61692212F-0996WE-TWILL, TEAL
MS13008B62792927.48F-1024WE-TWILL, PLATINUM
MS13008B58079840F-1025WE-TWILL, BLACK INDIGO
MS13008B61835934F-1656WE-TWILL, MINT
MS13008B61847212F-1656WE-TWILL, MINT
MS13008C44396715F-0929ECO WEAVE, PEWTER
MS13008D5900674.51F-1655CHENILLE TWEED, ROSETTE
MS13008D59006834.54F-1655CHENILLE TWEED, ROSETTE
MS13009B56043243.74V-0002VEGAN LEATHER, SNOW
MS13009C28963510F-0299TXTD BASKETWEAVE, FLAX
MS13009C6139965F-0700HEATHERED WEAVE, EUCALYPTUS
MS13009C58710525F-0701HEATHERED WEAVE, CAYENNE
MS13009C28195715F-0755HEATHERED CROSSHATCH, FEATHER GREY
MS13009C28196210F-0755HEATHERED CROSSHATCH, FEATHER GREY
MS13009C52411040.3F-0845PERF CROSS WEAVE, PEBBLE
MS13009C32760215F-0943PERF HEATHERED TWEED, IVORY
MS13009C61339311.9F-1028HEATHERED CROSSHATCH, NATURAL
MS13009D61385015.98F-0700HEATHERED WEAVE, EUCALYPTUS
MS13009D32773820F-0785HEATHERED TWEED, CHARCOAL
MS13009D62963612.6F-0785HEATHERED TWEED, CHARCOAL
MS13009D58682622.54F-0819HEATHERED TWEED, MARINE
MS13009D5868456.97F-0819HEATHERED TWEED, MARINE
MS13009D45226120F-1067HEATHERED CROSSHATCH, SLATE
MS13010B6343462F-1112WASHED CANVAS, FEATHER GREY
MS13010B63436018F-1112WASHED CANVAS, FEATHER GREY
MS13010B63943511.83F-1112WASHED CANVAS, FEATHER GREY
MS13010B63943714.5F-1112WASHED CANVAS, FEATHER GREY
MS13010B59000620F-1701LUXE BOUCLE,ANGORA BEIGE
MS13010C52417210F-1652DECO WEAVE, STONE
MS13010C6159086F-1809DRAWN DOTS, INDIGO
MS13010D4557846F-0792LUSTRE VELVET, DUSTY BLUSH
MS13010D4946791F-0792LUSTRE VELVET, DUSTY BLUSH
MS13010D5325238F-0792LUSTRE VELVET, DUSTY BLUSH
MS13010D58698620F-0793LUSTRE VELVET, CELESTIAL BLUE
MS13010D5171371F-0890PLUSH VELVET, WASABI
MS13010D5808275F-0890PLUSH VELVET, WASABI
MS13010D6081926F-0890PLUSH VELVET, WASABI
MS13010D4420063F-1139TEXTURED TWILL, KHAKI
MS13010D4420071F-1139TEXTURED TWILL, KHAKI
MS13010D5249743F-1659CANNES, SILVERSAGE
MS13010D62650326.74F-1703LUXE BOUCLE,STONE WHITE
MS13011B4250832F-1073ASTOR VELVET, EVERGREEN
MS13011B4460478F-1074ASTOR VELVET, DUSTY BLUSH
MS13011B58731735.3F-1075ASTOR VELVET, FROST GREY
MS13011B44604030F-1079ASTOR VELVET, STONE
MS13011B48532737F-1079ASTOR VELVET, STONE
MS13011B6162695F-1793ASTOR VELVET, PINK GRAPEFRUIT
MS13011C17526130.68F-0739TWEED, ASH
MS13011C17528345.1F-0739TWEED, ASH
MS13011C17528444F-0739TWEED, ASH
MS13011C17528542.8F-0739TWEED, ASH
MS13011C17528643F-0739TWEED, ASH
MS13011C17528742.2F-0739TWEED, ASH
MS13011C17528843.3F-0739TWEED, ASH
MS13011C17529039.4F-0739TWEED, ASH
MS13011C17529137.8F-0739TWEED, ASH
MS13011C19101541.5F-0739TWEED, ASH
MS13011C20235140.6F-0739TWEED, ASH
MS13011C49380212F-0739TWEED, ASH
MS13011C5238673F-0739TWEED, ASH
MS13011D5854632F-1074ASTOR VELVET, DUSTY BLUSH
MS13011D5872211F-1074ASTOR VELVET, DUSTY BLUSH
MS13011D45643810F-1075ASTOR VELVET, FROST GREY
MS13011D5875873F-1076ASTOR VELVET, IRON
MS13011D63960511.89F-1078ASTOR VELVET, STEEL BLUE
MS13011D57524715F-1080ASTOR VELVET, NICKEL
MS13011D57538630F-1080ASTOR VELVET, NICKEL
MS13011D4354002F-1082ASTOR VELVET, SLATE
MS13011D4354062F-1082ASTOR VELVET, SLATE
MS13011D57203115.65F-1082ASTOR VELVET, SLATE
MSFLOOR1633957525.16F-0227PERF VELVET, DOVE GREY
MSFLOOR1634009530.64F-0227PERF VELVET, DOVE GREY
MSFLOOR163947951.42F-0227PERF VELVET, DOVE GREY
MSFLOOR1633547425.59F-0357PERF VELVET, LAGOON
MSFLOOR163941133.37F-0357PERF VELVET, LAGOON
MSFLOOR163941542.12F-0357PERF VELVET, LAGOON
MSFLOOR163941745.95F-0357PERF VELVET, LAGOON
MSFLOOR163941954.7F-0357PERF VELVET, LAGOON
MSFLOOR163942047.05F-0357PERF VELVET, LAGOON
MSFLOOR1634822345.19F-0359PERF VELVET, STONE
MSFLOOR164186948.7F-0821WE-TWILL, STONE
MSFLOOR164187145.4F-0821WE-TWILL, STONE
MSFLOOR164187346.7F-0821WE-TWILL, STONE
MSFLOOR164187448.7F-0821WE-TWILL, STONE
MSFLOOR164187647F-0821WE-TWILL, STONE
MSFLOOR164187844.9F-0821WE-TWILL, STONE
MSFLOOR164187945.6F-0821WE-TWILL, STONE
MSFLOOR164188046.9F-0821WE-TWILL, STONE
MSFLOOR164188247.3F-0821WE-TWILL, STONE
MSFLOOR164188448.7F-0821WE-TWILL, STONE
MSFLOOR164188546.9F-0821WE-TWILL, STONE
MSFLOOR164188644.7F-0821WE-TWILL, STONE
MSFLOOR164188748.1F-0821WE-TWILL, STONE
MSFLOOR164188846.8F-0821WE-TWILL, STONE
MSFLOOR164188950.8F-0821WE-TWILL, STONE
MSFLOOR164189046.2F-0821WE-TWILL, STONE
MSFLOOR164181356F-0928ECO WEAVE, OYSTER
MSFLOOR164194858F-0928ECO WEAVE, OYSTER
MSFLOOR164195157F-0928ECO WEAVE, OYSTER
MSFLOOR164195258F-0928ECO WEAVE, OYSTER
MSFLOOR164195457F-0928ECO WEAVE, OYSTER
MSFLOOR164195557F-0928ECO WEAVE, OYSTER
MSFLOOR164195758F-0928ECO WEAVE, OYSTER
MSFLOOR164195857F-0928ECO WEAVE, OYSTER
MSFLOOR1578028503.5F-0978PERFORMANCE BASKETWEAVE, NATURAL
MSFLOOR1622126414.9F-1027YARN DYED LINEN WEAVE, STONE WHITE
MSFLOOR1579165428.1F-1034DISTRESSED VELVET, LIGHT TAUPE
MSFLOOR1579850425F-1034DISTRESSED VELVET, LIGHT TAUPE
MSFLOOR163762751.7F-1034DISTRESSED VELVET, LIGHT TAUPE
MSFLOOR163762847.1F-1034DISTRESSED VELVET, LIGHT TAUPE
MSFLOOR163763248.6F-1034DISTRESSED VELVET, LIGHT TAUPE
MSFLOOR163763346.8F-1034DISTRESSED VELVET, LIGHT TAUPE
MSFLOOR163763551.4F-1034DISTRESSED VELVET, LIGHT TAUPE
MSFLOOR163763645.9F-1034DISTRESSED VELVET, LIGHT TAUPE
MSFLOOR163763747.7F-1034DISTRESSED VELVET, LIGHT TAUPE
MSFLOOR163763851.6F-1034DISTRESSED VELVET, LIGHT TAUPE
MSFLOOR163763950F-1034DISTRESSED VELVET, LIGHT TAUPE
MSFLOOR163764046.7F-1034DISTRESSED VELVET, LIGHT TAUPE
MSFLOOR163764146.4F-1034DISTRESSED VELVET, LIGHT TAUPE
MSFLOOR163764246.4F-1034DISTRESSED VELVET, LIGHT TAUPE
MSFLOOR163764448F-1034DISTRESSED VELVET, LIGHT TAUPE
MSFLOOR163764549.8F-1034DISTRESSED VELVET, LIGHT TAUPE
MSFLOOR163765237.6F-1034DISTRESSED VELVET, LIGHT TAUPE
MSFLOOR1530739429.2F-1059DISTRESSED VELVET, MINERAL GREY
MSFLOOR1531016427.2F-1059DISTRESSED VELVET, MINERAL GREY
MSFLOOR1535260396F-1059DISTRESSED VELVET, MINERAL GREY
MSFLOOR163948850.2F-1059DISTRESSED VELVET, MINERAL GREY
MSFLOOR163948956.9F-1059DISTRESSED VELVET, MINERAL GREY
MSFLOOR163949145.9F-1059DISTRESSED VELVET, MINERAL GREY
MSFLOOR163949355.1F-1059DISTRESSED VELVET, MINERAL GREY
MSFLOOR163949644.2F-1059DISTRESSED VELVET, MINERAL GREY
MSFLOOR163949843.5F-1059DISTRESSED VELVET, MINERAL GREY
MSFLOOR164184153.6F-1059DISTRESSED VELVET, MINERAL GREY
MSFLOOR164184549.8F-1059DISTRESSED VELVET, MINERAL GREY
MSFLOOR164185247.4F-1059DISTRESSED VELVET, MINERAL GREY
MSFLOOR164185343.5F-1059DISTRESSED VELVET, MINERAL GREY
MSFLOOR164185549.5F-1059DISTRESSED VELVET, MINERAL GREY
MSFLOOR164185648.2F-1059DISTRESSED VELVET, MINERAL GREY
MSFLOOR164185850.3F-1059DISTRESSED VELVET, MINERAL GREY
MSFLOOR164186051.7F-1059DISTRESSED VELVET, MINERAL GREY
MSFLOOR164186148.8F-1059DISTRESSED VELVET, MINERAL GREY
MSFLOOR163942926.8F-1112WASHED CANVAS, FEATHER GREY
MSFLOOR163943128.2F-1112WASHED CANVAS, FEATHER GREY
MSFLOOR163943227F-1112WASHED CANVAS, FEATHER GREY
MSFLOOR163943327.7F-1112WASHED CANVAS, FEATHER GREY
MSFLOOR163943421.6F-1112WASHED CANVAS, FEATHER GREY
MSFLOOR163944125.7F-1112WASHED CANVAS, FEATHER GREY
MSFLOOR163944225.7F-1112WASHED CANVAS, FEATHER GREY
MSFLOOR163945528.3F-1112WASHED CANVAS, FEATHER GREY
MSFLOOR163945725.3F-1112WASHED CANVAS, FEATHER GREY
MSFLOOR163945831F-1112WASHED CANVAS, FEATHER GREY
MSFLOOR163945924.5F-1112WASHED CANVAS, FEATHER GREY
MSFLOOR163946027F-1112WASHED CANVAS, FEATHER GREY
MSFLOOR1634171521.7F-1693CHENILLE TWEED, IRONGATE
MSFLOOR163440143.5F-1693CHENILLE TWEED, IRONGATE
MSFLOOR1593446393.66V-0001VEGAN LEATHER,NUT
MSFLOOR1626619610.52V-0001VEGAN LEATHER,NUT
MSFLOOR163346643.74V-0003VEGAN LEATHER, CINDER
MSFLOOR163961543.74V-0003VEGAN LEATHER, CINDER
MSFLOOR160178331.71V-0004VEGAN LEATHER, MOLASSES
MSFLOOR264028859.08F-0443PERF VELVET, INK BLUE
MSFLOOR264029055.8F-0443PERF VELVET, INK BLUE
MSFLOOR264029156.35F-0443PERF VELVET, INK BLUE
MSFLOOR264029255.25F-0443PERF VELVET, INK BLUE
MSFLOOR264029354.16F-0443PERF VELVET, INK BLUE
MSFLOOR264029446.5F-0443PERF VELVET, INK BLUE
MST00363948225F-0227PERF VELVET, DOVE GREY
MST00363751415.32F-0359PERF VELVET, STONE
MST0035950010F-0447PERF VELVET, SHADOW
MST00463941429.54F-0357PERF VELVET, LAGOON
MST00463763044.8F-1034DISTRESSED VELVET, LIGHT TAUPE
MST00463949045.4F-1059DISTRESSED VELVET, MINERAL GREY
MST00463943628.7F-1112WASHED CANVAS, FEATHER GREY
MST00463944028.4F-1112WASHED CANVAS, FEATHER GREY
MST0066375054F-0359PERF VELVET, STONE
MST00663751244.86F-0359PERF VELVET, STONE
MST0075950140F-0447PERF VELVET, SHADOW
MST0076133823F-0840DECO WEAVE, FEATHER GREY
MST00764132255F-0928ECO WEAVE, OYSTER
MST00764132335F-0928ECO WEAVE, OYSTER
MST00764132544F-0928ECO WEAVE, OYSTER
MST00761400130F-0978PERFORMANCE BASKETWEAVE, NATURAL
MST00763762943.1F-1034DISTRESSED VELVET, LIGHT TAUPE
MST00760748353.9F-1622PERFORMANCE BASKET SLUB, DARK HORSERADISH
MST00763440443.2F-1693CHENILLE TWEED, IRONGATE


Macro:
VBA Code:
Sub Subtotal_Format()
'
' Subtotal_Format Macro
' Subtotal Bin Loc Count in Batch Column and Format
'

'
    Selection.Subtotal GroupBy:=1, Function:=xlCount, TotalList:=Array(2), _
        Replace:=True, PageBreaks:=False, SummaryBelowData:=False
    Columns("A:F").Select
    Selection.AutoFilter
    Range("A3").Select
    ActiveSheet.Range("$A$1:$F$345").AutoFilter Field:=1, Criteria1:=Array( _
        "Grand Count", "MS13001B Count", "MS13001C Count", "MS13001D Count", _
        "MS13002A Count", "MS13002B Count", "MS13002C Count", "MS13002D Count", _
        "MS13003B Count", "MS13003C Count", "MS13003D Count", "MS13004C Count", _
        "MS13004D Count", "MS13005B Count", "MS13005D Count", "MS13006B Count", _
        "MS13006C Count", "MS13006D Count", "MS13007B Count", "MS13007C Count", _
        "MS13007D Count", "MS13008A Count", "MS13008B Count", "MS13008C Count", _
        "MS13008D Count", "MS13009B Count", "MS13009C Count", "MS13009D Count", _
        "MS13010B Count", "MS13010C Count", "MS13010D Count", "MS13011B Count", _
        "MS13011C Count", "MS13011D Count", "MSFLOOR1 Count", "MSFLOOR2 Count", _
        "MST003 Count", "MST004 Count", "MST006 Count", "MST007 Count"), Operator:= _
        xlFilterValues
    Range("A2:F335").Select
    With Selection.Interior
        .PatternThemeColor = xlThemeColorAccent6
        .ThemeColor = xlThemeColorAccent6
        .TintAndShade = 0.399975585192419
        .PatternTintAndShade = 0.799981688894314
    End With
    Selection.Font.Bold = False
    Selection.Font.Bold = True
    ActiveSheet.Range("$A$1:$F$345").AutoFilter Field:=1
    Columns("A:A").Select
    Selection.Replace What:="Count", Replacement:=" ", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
    Range("A3").Select
End Sub
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Oh, Also, here is a screenshot showing the new Bin not being formatted. The find and replace is the only part that worked. Thank again to anyone who can help.
 

Attachments

  • Not Formatted Correctly.PNG
    Not Formatted Correctly.PNG
    24.4 KB · Views: 9
Upvote 0
Maybe the solution is to use a formula instead of subtotaling the data. I have been googling for the past three days, and while I have found lots of posts, I can't find this exact problem. It doesn't seem to be the known problem with conditional formatting and it's not a pivot table. It also doesn't seem to be a problem with my range in my macro. I'm just at a loss. I have the freedom to make the sheet however I want, so I don't have to do anything a certain way as long as the result is the same. I also need to be able to format quickly, which is why I used a macro in the first place. We are told when to refresh our main sheet and we have to count as soon as possible since the plant is still in production while we count.

Any ideas will be welcome!
 
Upvote 0
Your code refers to a specific range so if your query returns new data, it won't get included. I suggest you use Range("A1").Currentregion instead of specifying the number of rows.
 
Upvote 0
Your code refers to a specific range so if your query returns new data, it won't get included. I suggest you use Range("A1").Currentregion instead of specifying the number of rows.

Thank you so much for taking the time to help! I changed the range to your suggestion and it didn't work, so I changed a few more and it still isn't working. Could you please look at the new code and tell me where I should be changing it?

VBA Code:
Sub Subtotal_Format()
'
' Subtotal_Format Macro
' Subtotal Bin Loc Count in Batch Column and Format
'

'
    Selection.Subtotal GroupBy:=1, Function:=xlCount, TotalList:=Array(2), _
        Replace:=True, PageBreaks:=False, SummaryBelowData:=False
    Columns("A:F").Select
    Selection.AutoFilter
    Range("A3").Select
    Range("A1").CurrentRegion.AutoFilter Field:=1, Criteria1:=Array( _
        "Grand Count", "MS13001B Count", "MS13001C Count", "MS13001D Count", _
        "MS13002A Count", "MS13002B Count", "MS13002C Count", "MS13002D Count", _
        "MS13003B Count", "MS13003C Count", "MS13003D Count", "MS13004C Count", _
        "MS13004D Count", "MS13005B Count", "MS13005D Count", "MS13006B Count", _
        "MS13006C Count", "MS13006D Count", "MS13007B Count", "MS13007C Count", _
        "MS13007D Count", "MS13008A Count", "MS13008B Count", "MS13008C Count", _
        "MS13008D Count", "MS13009B Count", "MS13009C Count", "MS13009D Count", _
        "MS13010B Count", "MS13010C Count", "MS13010D Count", "MS13011B Count", _
        "MS13011C Count", "MS13011D Count", "MSFLOOR1 Count", "MSFLOOR2 Count", _
        "MST003 Count", "MST004 Count", "MST006 Count", "MST007 Count"), Operator:= _
        xlFilterValues
    Range("A1").CurrentRegion.Select
    With Selection.Interior
        .PatternThemeColor = xlThemeColorAccent6
        .ThemeColor = xlThemeColorAccent6
        .TintAndShade = 0.399975585192419
        .PatternTintAndShade = 0.799981688894314
    End With
    Selection.Font.Bold = False
    Selection.Font.Bold = True
    Range("A1").CurrentRegion.AutoFilter Field:=1
    Columns("A:A").Select
    Selection.Replace What:="Count", Replacement:=" ", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
    Range("A3").Select
End Sub
 
Upvote 0
What exactly does "didn't work" actually mean? What happened?
 
Upvote 0
What exactly does "didn't work" actually mean? What happened?

Oh sorry, It still didn't format the new data. (Making it bold and coloring the rows dark green.) So MST008 in post #2 still looks the same instead of being formatted like the others.
 
Upvote 0
I suspect your autofilter is the issue as it is filtering for a specific list. Try amending it from this:

Code:
ActiveSheet.Range("$A$1:$F$345").AutoFilter Field:=1, Criteria1:=Array( _
"Grand Count", "MS13001B Count", "MS13001C Count", "MS13001D Count", _
"MS13002A Count", "MS13002B Count", "MS13002C Count", "MS13002D Count", _
"MS13003B Count", "MS13003C Count", "MS13003D Count", "MS13004C Count", _
"MS13004D Count", "MS13005B Count", "MS13005D Count", "MS13006B Count", _
"MS13006C Count", "MS13006D Count", "MS13007B Count", "MS13007C Count", _
"MS13007D Count", "MS13008A Count", "MS13008B Count", "MS13008C Count", _
"MS13008D Count", "MS13009B Count", "MS13009C Count", "MS13009D Count", _
"MS13010B Count", "MS13010C Count", "MS13010D Count", "MS13011B Count", _
"MS13011C Count", "MS13011D Count", "MSFLOOR1 Count", "MSFLOOR2 Count", _
"MST003 Count", "MST004 Count", "MST006 Count", "MST007 Count"), Operator:= _
        xlFilterValues

to this:

Code:
Activesheet.range("A1").currentregion.autofilter field:=1, criteria1:="*Count"
 
Upvote 0
I suspect your autofilter is the issue as it is filtering for a specific list. Try amending it from this:

Code:
ActiveSheet.Range("$A$1:$F$345").AutoFilter Field:=1, Criteria1:=Array( _
"Grand Count", "MS13001B Count", "MS13001C Count", "MS13001D Count", _
"MS13002A Count", "MS13002B Count", "MS13002C Count", "MS13002D Count", _
"MS13003B Count", "MS13003C Count", "MS13003D Count", "MS13004C Count", _
"MS13004D Count", "MS13005B Count", "MS13005D Count", "MS13006B Count", _
"MS13006C Count", "MS13006D Count", "MS13007B Count", "MS13007C Count", _
"MS13007D Count", "MS13008A Count", "MS13008B Count", "MS13008C Count", _
"MS13008D Count", "MS13009B Count", "MS13009C Count", "MS13009D Count", _
"MS13010B Count", "MS13010C Count", "MS13010D Count", "MS13011B Count", _
"MS13011C Count", "MS13011D Count", "MSFLOOR1 Count", "MSFLOOR2 Count", _
"MST003 Count", "MST004 Count", "MST006 Count", "MST007 Count"), Operator:= _
        xlFilterValues

to this:

Code:
Activesheet.range("A1").currentregion.autofilter field:=1, criteria1:="*Count"

That did it! Thank you so much!
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,912
Members
452,366
Latest member
TePunaBloke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top