excel - Show/hide columns based on input value -


i have 1 input sheet "sheet i", input cell: c3, input value integer, such 1, 2, 3... . output sheets "out 1", "out 2", "out 3", ..."out 10". output sheets contain content a2 g36, while others contain information a2 h36 or t36. ideally, see columns (starting column c) conditionally based on value in $c$3 in sheet i. here logic:

  • if input value = 1, show column a, column b , column c
  • if input value = 2, show column a, column b , column d
  • if input value = 6, show column a, column b , column h
  • .....

right have vba, input value in code set static number. can advise how should change code in order make work?

private sub workbook_sheetcalculate(byval sh object) dim sharray dim dim myrange, c range  application.screenupdating = false application.enableevents = false sharray = array("out 1", "out 2", "out 3", "out 4", "out 5",.. "out 10") = lbound(sharray) ubound(sharray)     set myrange = sheets(sharray(i)).range("a:t")     each c in myrange         sheets(sharray(i)).rows(c.column).hidden = c.value = "??"     next c next application.enableevents = true application.screenupdating = true end sub 

no quite sure if looking should try this.

if inputvalue = 1 sheets(sharray(i)).columns("a:c").entirecolumn.hidden = false elseif inputvalue = 2  '... elseif inputvalue = 3   end if  

Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -