Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Select Variable Number of Columns
I want to select a variable number of columns. I know I want to start in
Column C (3) and I know how many columns out I wish to go but I can't seem to figure out the right syntax for selecting these columns. After selection I wish to hide them. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Select Variable Number of Columns
Hi, try this. If you want to unhide all columns just unrem
Columns.Hidden = False and run the macro. Sub Hide_cols() Application.ScreenUpdating = False Dim col As Integer, i As Integer col = Val(InputBox("Give the last column number")) For i = 3 To col Columns(i).Hidden = True Next i Application.ScreenUpdating = True 'Columns.Hidden = False End Sub regards |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Select Variable Number of Columns
Just wondering, would the hiding routine go faster if I were to select a
range of columns to hide, rather than just one column at a time? That is what I was originally trying to do and couldn't get it right. If you don't think so, use what you gave me. Another issue: Do you know if I have cells within the column protected, I can't seem to hide the column. Do you know how to allow protected cells to be hidden and still be protected? |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Select Variable Number of Columns
On Jul 8, 2:12 pm, Mike H. wrote:
Just wondering, would the hiding routine go faster if I were to select a range of columns to hide, rather than just one column at a time? That is what I was originally trying to do and couldn't get it right. If you don't think so, use what you gave me. Another issue: Do you know if I have cells within the column protected, I can't seem to hide the column. Do you know how to allow protected cells to be hidden and still be protected? You are right, bad habit of using iteration ;). I think this will wokr much faster Sub Hide_cols() Dim col As String, i As Integer col = CStr(InputBox("Give the last column letter")) Range("c:" & col).Columns.Hidden = True 'Columns.Hidden = False End Sub as for your other question try to choose toolsprotectionprotect worksheet and set alowance to format columns, that should do. |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Select Variable Number of Columns
I want to select a variable number of columns.
Hi. One way: Sub Demo() Dim n n = 5 Columns(3).Resize(, n).Hidden = True End Sub -- HTH :) Dana DeLouis "Mike H." wrote in message ... I want to select a variable number of columns. I know I want to start in Column C (3) and I know how many columns out I wish to go but I can't seem to figure out the right syntax for selecting these columns. After selection I wish to hide them. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Adding variable number of columns | Excel Worksheet Functions | |||
sum number of columns based on variable value | Excel Discussion (Misc queries) | |||
HIDING A VARIABLE NUMBER OF COLUMNS | Excel Programming | |||
select columns by variable | Excel Programming | |||
adding variable number of columns | Excel Worksheet Functions |