Hiding columns

S

scottwilsonx

Hi everyone, can anyone help !?

I have a table of information, from A19 to F50 where column has title
and B to F data. The table is linked to other worksheets using th
INDIRECT function and references cell A5 to get the appropriat
sheetname.

What I would like to do is create a VBA macro that will automaticall
hide the rows with no data in either column B or E. is this possible ?


Thanks for any and all help.

Best wishes
Scott
 
M

Mike Fogleman

Hi Scott, This code will do that for you

Sub HideEmpty()
Dim r As Integer
For r = 19 To 50
If Range("B" & r).Value = "" Or Range("E" & r).Value = "" Then
Rows(r).EntireRow.Hidden = True
Next r
End Sub

Mike F
 
B

BrianB

Someting like this :-


Code
-------------------
Sub HideRows()
For r = 20 To 50
If Cells(r, 2).Value = "" Or Cells(r, 5).Value = "" Then
Rows(r).EntireRow.Hidden = True
End If
Next
End Sub
 
S

scottwilsonx

Thanks both,

Not sure if I am missing something simple. But the following code won'
run, and instead gives me the following error "compile error nex
without for". Any ideas !?

Thanks

Sub HideEmpty()
Dim r As Integer
For r = 19 To 50
If Range("B" & r).Value = "" Or Range("E" & r).Value = "" Then
Rows(r).EntireRow.Hidden = True
Next r
End Sub
 
S

scottwilsonx

Sorry everyone, Ive worked it out. Missing an End If !
Thanks for your help.

Best wishes
Scott
 
Top