ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Hiding columns (https://www.excelbanter.com/excel-programming/305009-hiding-columns.html)

scottwilsonx[_10_]

Hiding columns
 
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

--
Message posted from http://www.ExcelForum.com


Mike Fogleman

Hiding columns
 
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

"scottwilsonx " wrote in
message ...
Hi everyone, can anyone help !?

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

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


Thanks for any and all help.

Best wishes
Scott.


---
Message posted from http://www.ExcelForum.com/




BrianB

Hiding columns
 
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

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


--
Message posted from http://www.ExcelForum.com


scottwilsonx[_11_]

Hiding columns
 
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

--
Message posted from http://www.ExcelForum.com


scottwilsonx[_12_]

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

Best wishes
Scott

--
Message posted from http://www.ExcelForum.com



All times are GMT +1. The time now is 04:21 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com