vba - Excel Combobox _Click activating on Pivot table refresh -


i have combobox on same sheet few pivot tables. combobox updates pivot table filters depending on what's selected.

the problem is, when pivot table refreshes (to set new filters) active combo box _clickfunction, starting loop.

is there way around this? why pivot table refresh activating combo box?

this code inside _click event:

private sub cmb_skuselect_click()     dim xlsheetsort worksheet     dim lastrow long     dim xlcell range     dim skuvalue integer      set xlsheetsort = activeworkbook.worksheets("sort")      lastrow = xlsheetsort.range("a1").end(xldown).row      xlsheetsort.range("b1:b" & lastrow)         set xlcell = .find(cmb_skuselect.value, lookin:=xlvalues)         if not xlcell nothing             skuvalue = xlsheetsort.range("a" & xlcell.row).value         end if     end      updatepivot skuvalue end sub 

updatepivot:

public sub updatepivot(byval sku integer)     dim pt pivottable     dim pt2 pivottable     dim field pivotfield     dim field2 pivotfield     dim newsku string      set pt = worksheets("sku inventory").pivottables("skuinfo")     set field = pt.pivotfields("sku number")      set pt2 = worksheets("sku inventory").pivottables("inventoryinfo")     set field2 = pt2.pivotfields("sku number")      newsku = sku      pt         field.currentpage = newsku         pt.refreshtable     end      pt2         field2.currentpage = newsku         pt2.refreshtable     end end sub 

thry this

public sub updatepivot(byval sku integer)     dim pt pivottable     dim pt2 pivottable     dim field pivotfield     dim field2 pivotfield     dim newsku string      set pt = worksheets("sku inventory").pivottables("skuinfo")     set field = pt.pivotfields("sku number")      set pt2 = worksheets("sku inventory").pivottables("inventoryinfo")     set field2 = pt2.pivotfields("sku number")      newsku = sku      pt         field             .orientation = xlhidden             pt.refreshtable             .orientation = xlpagefield             .currentpage = newsku         end     end      pt2         field2             .orientation = xlhidden             pt2.refreshtable             .orientation = xlpagefield             .currentpage = newsku         end      end end sub 

Comments

Popular posts from this blog

What is happening when Matlab is starting a "parallel pool"? -

angular - DownloadURL return null in below code -

php - Cannot override Laravel Spark authentication with own implementation -