hide rows of blank cells

G

Galen

this is the code i have

Sub StatesCleanup()
Dim rngCell As Range
Dim rng As Range

Set rng = Sheets("Summary").Range("c24:c74")

For Each rngCell In rng.Cells
If rngCell.Value = "" Then
rngCell.EntireRow.Hidden = True
End If
Next rngCell


End Sub


but there is a second range (d24:d74) that may ahve different cells that are
blank. If i just set the rang to c24:d74 the it hides rows that are blank in
one cloumn but have a vlue in the other. I only want to hide rows that are
blank in both columns. any help would be greatly appreciated thanks!
 
J

Jacob Skaria

Try the below

Sub StatesCleanup()
Dim rngCell As Range
Dim rng As Range

Set rng = Sheets("Summary").Range("c24:c74")

For Each rngCell In rng.Rows
If Trim(rngCell.Offset(, 0) & rngCell.Offset(, 1)) = "" Then
rngCell.EntireRow.Hidden = True
End If
Next rngCell

End Sub

If this post helps click Yes
 
S

stanleydgromjr

Galen,

Try:


Code
-------------------


Option Explicit
Sub StatesCleanup()
Dim a As Long
For a = 24 To 74 Step 1
If Cells(a, "C") = "" And Cells(a, "D") = "" Then Rows(a).EntireRow.Hidden = True
Next a
End Sub


-------------------



Have a great day,
Sta
 
G

Galen

that worked great! thanks
--
Thanks,

Galen


Jacob Skaria said:
Try the below

Sub StatesCleanup()
Dim rngCell As Range
Dim rng As Range

Set rng = Sheets("Summary").Range("c24:c74")

For Each rngCell In rng.Rows
If Trim(rngCell.Offset(, 0) & rngCell.Offset(, 1)) = "" Then
rngCell.EntireRow.Hidden = True
End If
Next rngCell

End Sub

If this post helps click Yes
 

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