Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Hi Ron
Try this: Sub HideEmptyRows() StartRow = 12 For Each col In Columns("E:AI") ColAdr = col.Address TargetCol = IIf(Mid(col.Address, 4, 1) = "$", _ Mid(col.Address, 2, 1), Mid(col.Address, 2, 2)) LastRow = Range(TargetCol & Rows.Count).End(xlUp).Row RowCount = Range(TargetCol & 12, TargetCol & LastRow).Rows.Count EmptyRows = WorksheetFunction.CountBlank _ (Range(TargetCol & 12, TargetCol & LastRow)) If RowCount = EmptyRows Then Columns(TargetCol).Hidden = True Next End Sub Regards, Per skrev i meddelelsen ... Hi guys, I've searched and tried to reuse some of the code to fit my needs but, so far I've not been successful. So, my last resort is to ask for your assistance. I'm trying to Loop through Columns E:AI's used range, beginning with row 12. Number of rows could be from 1 to 5000 rows. I need to hide columns that have blanks in all rows (12 to ?) for that column. Appreciate your assistance and thank you in advance. Ron |
#2
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
On Apr 12, 12:30*pm, "Per Jessen" wrote:
Hi Ron Try this: Sub HideEmptyRows() StartRow = 12 For Each col In Columns("E:AI") * * ColAdr = col.Address * * TargetCol = IIf(Mid(col.Address, 4, 1) = "$", _ * * * * Mid(col.Address, 2, 1), Mid(col.Address, 2, 2)) * * LastRow = Range(TargetCol & Rows.Count).End(xlUp).Row * * RowCount = Range(TargetCol & 12, TargetCol & LastRow).Rows.Count * * EmptyRows = WorksheetFunction.CountBlank _ * * * * (Range(TargetCol & 12, TargetCol & LastRow)) * * If RowCount = EmptyRows Then Columns(TargetCol).Hidden = True Next End Sub Regards, Per skrev i ... Hi guys, I've searched and tried to reuse some of the code to fit my needs but, so far I've not been successful. *So, my last resort is to ask for your assistance. *I'm trying to Loop through Columns E:AI's used range, beginning with row 12. Number of rows could be from 1 to 5000 rows. I need to hide columns that have blanks in all rows (12 to ?) for that column. *Appreciate your assistance and thank you in advance. *Ron- Hide quoted text - - Show quoted text - Hi Per Jessen... thank you for your assistance. My mistake. Apparently there is something in the cells I'm considering blank. I'm looking to hide the columns if there are no user input of text or numeric. Your code does not work in the target worksheet but, does work when I paste the data to another worksheet and run your code. So, I know your code works, my sheet's cells must not be blank. Can your code be edited to do that? Thank you for your assistance. Ron |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How to UN-hide column A? | Excel Worksheet Functions | |||
UN-hide column A???? | Excel Discussion (Misc queries) | |||
Hide column or row based on a cell in the column or row? | Excel Discussion (Misc queries) | |||
test if column isblank | Excel Worksheet Functions | |||
hide column | New Users to Excel |