Hide columns randomly using macro !!

Hemalata

New Member
Joined
Aug 7, 2009
Messages
5
Hi,
I am stuck up in following condition using macro...

I have large data in worksheet having 200 Columns and 60 rows in "sheet1".

Concept is -
User inputs some number where that number's column only be visible and rest 199 columns and their data will be invisible.
( Eg - number entered 2. Column No 2 will be visible only; rest of columns 1 & 3-200 will be invisible)

Now Everytime as user enters number that column will be visible column.
So i have range of 0 to 200 numbers, any of which user can enter and other than selected column should be invisible.

i am not getting how to handle 200 columns data visible n invisible. Here its not any specific column to hide and show rest all.
Everytime there will be differnt number entered and different columns to hide.

How to handle such chunk of data with minimum code.

Anyone can help me please give suggession.

Thnx
HSD
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
You want the 60 riows in those ciolumns hideen, and the rest of the rows to be visible? Not possible.
 
Upvote 0
This will prompt the user for a number and show only the indicated column.
Code:
Dim columnToShow As Long
columnToShow = Application.InputBox("Show Column number?", Type:=1)
If 0 < columnToShow And columnToShow < 201 Then
    With ActiveSheet
        .Range("A1").Resize(, 200).EntireColumn.Hidden = True
        .Columns(columnToShow).Hidden = False
    End With
End If
 
Upvote 0
You want the 60 riows in those ciolumns hideen, and the rest of the rows to be visible? Not possible.

I want that when user will enter some number Only that number's column n data should be visible and rest all columns with their data should be invisible...
 
Upvote 0
Hi

I have tried that simplified code on small sample sheet..
It working fine..

Its great help.. now I can connect my graphs to columns and operate upon graphs visibility....

Thnx alott !!
 
Last edited:
Upvote 0
When I run the code, the screen scrolls, hiding the left-most (user entered) column, but the column is visible when scrolled left. Changing to this will un-scroll the window.
Code:
Dim columnToShow As Long
columnToShow = Application.InputBox("Show Column number?", Type:=1)
If 0 < columnToShow And columnToShow < 201 Then
    With ActiveSheet
        .Range("A1").Resize(, 200).EntireColumn.Hidden = True
        .Columns(columnToShow).Hidden = False
        Application.Goto .Cells(1, columnToShow)
    End With
End If
 
Upvote 0
I have used this code, its doing well but.... now I am representing those columns to chart and respective columns and their graph is not working... w/o graph only columns, its working but wid same column applied on graphs its not working,...

Only for columns code is working .. but when i co relate them to graph its not working on them..
why same code is not applicable over chart graphs... graphs should be visible n invisible as per columns and given code above... but its not applicable over my graphs stage...
 
Upvote 0

Forum statistics

Threads
1,214,601
Messages
6,120,462
Members
448,965
Latest member
grijken

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