Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Hiding rows with no content to right of Column B

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.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Hiding rows with no content to right of Column B

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

"Aidan" wrote:

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.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Hiding rows with no content to right of Column B

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

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Aidan" wrote in message
...
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.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Hiding rows with no content to right of Column B

Thanks Mike, I will give it a go.

"Mike H" wrote:

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

"Aidan" wrote:

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.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Hiding rows based on cell content Doug Howell Excel Programming 6 November 9th 09 08:10 PM
hiding unued rows and column Link[_2_] Excel Programming 3 July 2nd 09 04:20 PM
Hiding rows based on cell content brutus Excel Programming 5 November 15th 05 03:39 AM
macro - hiding rows given a cells content Greg Stevens Excel Programming 3 October 15th 04 09:25 PM
Hiding rows based on cell content alistair01[_4_] Excel Programming 2 February 3rd 04 01:58 PM


All times are GMT +1. The time now is 07:10 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"