Hiding rows with no content to right of Column B

A

Aidan

Can someone provide me with code that hides any row from Row 11 to Row 60 if
there is no content in the row to the right of Column B for the row in
2question.


Thanks in advance,


Aidan.
 
M

Mike H

Hi,

Paste this in a standard module and it works on the active sheet

Sub Marine()
Dim P As Long
P = Rows(1).Columns.Count
Dim copyrange As Range
For x = 11 To 60
If WorksheetFunction.CountA(Range(Cells(x, 3), Cells(x, P))) = 0 Then
If copyrange Is Nothing Then
Set copyrange = Rows(x).EntireRow
Else
Set copyrange = Union(copyrange, Rows(x).EntireRow)
End If
End If
Next
If Not copyrange Is Nothing Then
copyrange.EntireRow.Hidden = True
End If
End Sub

Mike
 
D

Don Guillett

Option Explicit
Sub HideRowsifLastColisB()
Dim i As Long
For i = Cells(Rows.Count, 1). _
End(xlUp).Row To 1 Step -1
If Cells(i, Columns.Count).End(xlToLeft). _
Column = 2 Then Rows(i).Hidden = True
Next i
End Sub
 
A

Aidan

Thanks Mike, I will give it a go.

Mike H said:
Hi,

Paste this in a standard module and it works on the active sheet

Sub Marine()
Dim P As Long
P = Rows(1).Columns.Count
Dim copyrange As Range
For x = 11 To 60
If WorksheetFunction.CountA(Range(Cells(x, 3), Cells(x, P))) = 0 Then
If copyrange Is Nothing Then
Set copyrange = Rows(x).EntireRow
Else
Set copyrange = Union(copyrange, Rows(x).EntireRow)
End If
End If
Next
If Not copyrange Is Nothing Then
copyrange.EntireRow.Hidden = True
End If
End Sub

Mike
 

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