hide a column

V

vikram

hi

can u help me with this

what i want is that if in a column there is written "Blank" a comman
that hides that particular column

plz help me with thi
 
V

vikram

thank u so much

but this will look in row 1 only
can we have it for all rows and a smaller one if it is possible

thank u so much
i really appreciate ur hel
 
V

vikram

hi job!

"Blank" written can be in any column and in any row. and if it is
want to hide that column

thank u so much for ur hel
 
F

Frank Kabel

Hi
o.k. try the following:
Sub hide_columns()
Dim rng as range
dim cell as range
set rng = activesheet.usedrange
application.screenupdating=False
For each cell in rng
If Cell.Value = "Blank" Then
Columns(cell.column).hidden = True
End If
Next cell
application.screenupdating=True
End Sub
 
J

Job

Ok,

Try this.

Sub HideIt()

Selection.CurrentRegion.Select
For Each Cell In Selection
'if you wanted to literally check each cell..I wouldn't recommend as i
would take a long time.
'For Each Cell In ActiveSheet.Cells
If Cell.Value = "Blank" Then
Cell.EntireColumn.Hidden = True

End If
Next Cell

End Su
 
V

vikram

thank u so much but if i want to check only column : A,B,C,D then wha
is the way out

thanks agai
 
J

Job

vikram said:
*but the macro is not working, i have checked it twice *

Are you sure the value in the cell is actually "Blank"? you could us
the 'like' that we used earlier and put Value Like "*Blank*"

Try that..
 
F

Frank Kabel

Hi
try
Sub hide_columns()
Dim Col_index as integer
Dim row_index as long
Dim lastrow as long

application.screenupdating=False
For col_index = 1 to 4
lastrow = ActiveSheet.Cells(Rows.count,
col_index).End(xlUp).row
for row_index = 1 to lastrow
if cells(row_index,col_index).value = "Blank" then
columns(col_index).hidden=True
exit for
end if
next row_index
next col_index
application.screenupdating=True
End Sub
 
F

Frank Kabel

Hi
have you tried my macro (see below). Just inserted it in your workbook
and it hides the columns

----
Sub hide_columns()
Dim Col_index as integer
Dim row_index as long
Dim lastrow as long

application.screenupdating=False
For col_index = 1 to 4
lastrow = ActiveSheet.Cells(Rows.count, _
col_index).End(xlUp).row
for row_index = 1 to lastrow
if cells(row_index,col_index).value = "Blank" then
columns(col_index).hidden=True
exit for
end if
next row_index
next col_index
application.screenupdating=True
End Sub
 
Top