Problem creating a macro

D

Denise Reaves

I am still trying to learn the in's and out's of macros. I need help.
I have a spreadsheet with a range from A1:a3200. I have started a
macro to find some text in the H column. This macro keeps deleting
the headers in the first 2 rows. Also, I need to find a way to hide
rows that have the number 1 in columns X, AC, AH, AM and AR. Here is
what I have so far.


Sub P690_Qtr1_Macro()


Dim rngCell As Range
Application.ScreenUpdating = False
With ActiveSheet
Intersect(.UsedRange, _
Columns("H")).EntireRow.Hidden = False
For Each rngCell In Intersect(.UsedRange, _
Columns("H"))
If rngCell = ("AIX") = False And _
rngCell = ("AIX - P690") = False And _
rngCell = ("AIX - P660") = False And _
rngCell = ("AIX - P630") = False Then _
rngCell.EntireRow.Hidden = True

Next rngCell

End With
Application.ScreenUpdating = True
End Sub

I haven't been successful at getting past this point. Any help that
you can give is GREATLY appreciated.

Denise Reaves
New Member
 
D

Dave Peterson

Did you mean that x, ac, ah, am, and ar all had to be 1's or any of them could
be a 1 (to hide the row)?

I guessed any of them:

Option Explicit

Sub P690_Qtr1_Macro()

'X, AC, AH, AM and AR
Dim rngCell As Range
Application.ScreenUpdating = False
With ActiveSheet
Intersect(.UsedRange, .Columns("H")).EntireRow.Hidden = False
For Each rngCell In Intersect(.UsedRange, .Rows("3:65536"), Columns("H"))
If (rngCell <> "AIX" _
And rngCell <> "AIX - P690" _
And rngCell <> "AIX - P660" _
And rngCell <> "AIX - P630") _
Or (.Cells(rngCell.Row, "x") = 1 _
And .Cells(rngCell.Row, "AC") = 1 _
And .Cells(rngCell.Row, "AH") = 1 _
And .Cells(rngCell.Row, "AM") = 1 _
And .Cells(rngCell.Row, "AR") = 1) Then
rngCell.EntireRow.Hidden = True
End If
Next rngCell

End With
Application.ScreenUpdating = True
End Sub
 

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

Top