excel vba - Macro to show/hide a worksheet based on date value -


i have excel workbook created executable data days of month on separate worksheets. 'sheet 1' of executable has days of month listed. write macro show/hide worksheets based on date in 'sheet 1'.

for instance, if data month of jan has days 1,2,3,4,5,11,12 displayed macro should show corresponding worksheets day1, day2, day3, day4,day5 , hide day6 through day10 , show day11 , day12. pointers appreciated.

thank you.

public sub setsheetvisiblity()    'load data sheet 1 collection   'i'm making assumption have days listed horizontally    '1a 1*    dim currentcolumn integer   dim activedaycollection collection    currentcolumn = 1   set activedaycollection = new collection    while cells(currentcolumn, 1).value <> ""      activedaycollection.add cells(currentcolumn, 1).value       currentcolumn = currentcolumn + 1   wend    'make every sheet invisible/visible   each currentworksheet worksheet in worksheets      if currentworksheet.name == "day" + activedaycollection.item 1       currentworksheet.visible = true       activedaycollection.remove 1     else        currentworksheet.visible = false     end if    next currentworksheet end sub 

the code works off of assumption days in first sheet in increasing order, sheets named day###, ### day number, , have add line manually unhide first sheet. don't have vba me code might have syntax errors, should going in right direction.


Comments

Popular posts from this blog

jQuery Ajax Render Fragments OR Whole Page -

javascript - Iterate over array and calculate average values of array-parts -

java - Simple Command Line calculator -