Hide rows if they equal...

  • Thread starter Thread starter Rutgers_Excels
  • Start date Start date
R

Rutgers_Excels

I want to use VB to write a code that will allow me to hide rows in the
range A1:A100 if they say "not used". Any help?

Thanks,

Brian
 
Hi Brian

One way :
You can use Data>AutoFilter

Choose custom in the list and use
does not equal "not used"
 
Ron,

That is the effect I want to get, however, i would like to know i
there is a "cleaner" looking way to accomplish this same task usin
visual basic. I have created a database that will be sent to othe
funtional departments and I don't want them to be able to mess aroun
with the filtering. I would like to use a code that is similar t
this....

Sub HideRows()
Range("A1:A100").Select
Selection.SpecialCells(xlCellTypeBlanks).Select
Selection.EntireRow.Hidden = True
End Sub

...but instead of hiding blank rows I'd like to be able to hide row
that say "not used".

Thanks for your hel
 
Try this

Sub Example2()
Dim Lrow As Long
Dim CalcMode As Long
Dim StartRow As Long
Dim EndRow As Long
With Application
CalcMode = .Calculation
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With

With ActiveSheet
.DisplayPageBreaks = False
StartRow = 1
EndRow = 100
For Lrow = EndRow To StartRow Step -1
If IsError(.Cells(Lrow, "A").Value) Then
'Do nothing, This avoid a error if there is a error in the cell

ElseIf .Cells(Lrow, "A").Value = "not used" Then .Rows(Lrow).Hidden = True

End If
Next
End With
With Application
.ScreenUpdating = True
.Calculation = CalcMode
End With
End Sub
 
That works perfectly. Did exactly what I wanted it to do.

Thank you very much for you help!

Bria
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top