PDA

View Full Version : VBA code required to unhide multiple sheets



adil mehboob
08-08-2014, 10:06 PM
In Excel 2010:
I have a main sheet i.e (Sheet1) --Usually default sheet in Excel.
I want to add a combo box in this Sheet1.

I have four other sheets too in same workbook that is opened i.e. (Sheet2,Sheet3,Sheet4,Sheet5,)
Now i want to add only Sheet2 name and Sheet4 name in that combo box.

After that when i click on Sheet2, it should open Sheet2 and Sheet3.
Similarly, When i click on sheet4, it should open Sheet4 and Sheet5.

is there any VBA code for this ?? Please help me in this regard..

Bob Phillips
08-09-2014, 02:18 AM
Why don't you get the user to select those he/she wants to unhide, rather than second guessing them?

adil mehboob
08-09-2014, 03:35 AM
Why don't you get the user to select those he/she wants to unhide, rather than second guessing them?



Actually there is some addtional work in sheet 3 which i want to open with sheet 2 as soon as user will click to unhide sheet 2..

westconn1
08-09-2014, 04:52 PM
in the click event for the combo


num = right(combo.text, 1)
for each sh in worksheets
if sh.name = "sheet" & num or sh.name = "sheet" & num + 1 or sh.name = "sheet1" then
sh.visible = true
else
sh.visible = false
end if
next

adil mehboob
08-10-2014, 09:41 PM
in the click event for the combo


num = right(combo.text, 1)
for each sh in worksheets
if sh.name = "sheet" & num or sh.name = "sheet" & num + 1 or sh.name = "sheet1" then
sh.visible = true
else
sh.visible = false
end if
next






kindly tell me how will i process with the above code. from where i should start?

westconn1
08-11-2014, 02:32 AM
kindly tell me how will i process with the above code. from where i should start?as suggested above
in the click event for the combo