Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,533
Default Hide Column If Usedrange of Column ISBLANK

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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 6
Default Hide Column If Usedrange of Column ISBLANK

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
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
How to UN-hide column A? verizon newsgroup Excel Worksheet Functions 3 March 9th 08 11:04 AM
UN-hide column A???? The Hun Excel Discussion (Misc queries) 2 February 23rd 08 06:37 AM
Hide column or row based on a cell in the column or row? SacGuy Excel Discussion (Misc queries) 0 January 24th 06 06:51 PM
test if column isblank Spike Excel Worksheet Functions 3 November 29th 05 02:06 PM
hide column varun New Users to Excel 1 December 3rd 04 02:13 AM


All times are GMT +1. The time now is 03:05 AM.

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

About Us

"It's about Microsoft Excel"