Solved

macro help

Posted on 2011-02-15
8
346 Views
Last Modified: 2012-05-11
Experts, attached is the code a friend wrote for me a while ago. Is it possible to add another condition to this code that checks another range(BD5:BD600) for the same thing as well? In other words, if a cell aq15=0 but bd15=10 then I don't want to hide that row. Pls let me know. tks.
mc

Application.ScreenUpdating = False

Dim cell As Range
Range("aq5:aq600").Select
For Each cell In Selection
If Not IsEmpty(cell) And cell.Value = 0 Then
cell.EntireRow.Hidden = True
End If
Next cell
Range("a1").Select
Application.ScreenUpdating = True
0
Comment
Question by:mc7560
8 Comments
 
LVL 1

Expert Comment

by:Anthony2oo5
ID: 34898049
Application.ScreenUpdating = False

Dim cell As Range
Range("aq5:aq600").Select
For Each cell In Selection
If Not IsEmpty(cell) And cell.Value = 0 Then
cell.EntireRow.Hidden = True
End If
Next cell

Range("BD5:BD600").Select
For Each cell In Selection
If Not IsEmpty(cell) And cell.Value = 0 Then
cell.EntireRow.Hidden = True
End If
Next cell

Range("a1").Select
Application.ScreenUpdating = True
0
 
LVL 11

Expert Comment

by:Runrigger
ID: 34898097
Dim cell As Range
Range("aq5:aq600").Select
For Each cell In Selection
If (Not IsEmpty(cell) And cell.Value = 0) and (Not IsEmpty(cell.offset(0,13)) And cell.offset(0,13).Value = 0) Then
cell.EntireRow.Hidden = True
End If
Next cell
Range("a1").Select
Application.ScreenUpdating = True
0
 
LVL 24

Accepted Solution

by:
StephenJR earned 500 total points
ID: 34898102
This perhaps?
Sub x()

Application.ScreenUpdating = False

Dim cell As Range

For Each cell In Range("aq5:aq600")
    If Not IsEmpty(cell) And cell.Value = 0 And Not IsEmpty(cell.Offset(, 13)) And cell.Offset(, 13).Value = 0 Then
        cell.EntireRow.Hidden = True
    End If
Next cell

Application.ScreenUpdating = True

End Sub

Open in new window

0
 
LVL 11

Expert Comment

by:Runrigger
ID: 34898122
Anthony, author wants an "inclusive" condition, I think?
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Closing Comment

by:mc7560
ID: 34898242
Stephen, thanks that did it. Have a great day.
0
 
LVL 11

Expert Comment

by:Runrigger
ID: 34898258
Any reason why mine was treated any differently? Its exactly the same!
0
 
LVL 24

Expert Comment

by:StephenJR
ID: 34898266
Thank you mc7560, glad it worked, but Runrigger posted the same solution ...
0
 
LVL 11

Expert Comment

by:Runrigger
ID: 34898271
Not worried about the pionts, but worth making a note of any error should future queries be made on this subject.
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

A2 = A1 That kind of cell reference is relative.  If you copy it from A2 to B2, then B2 will get this: B2 = B1 That's all fine and good, but if you then insert a new row above row 2, you'll find: A3 = A1 B3 = B1 This is intentional. …
A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now