MrExcel Message Board


Go Back   MrExcel Message Board > Question Forums > Excel Questions

Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only.

Reply
 
Thread Tools Display Modes
Old Mar 30th, 2004, 06:00 AM   #1
Excel-ent
 
Join Date: Mar 2004
Location: Dubai
Posts: 338
Default Hiding Rows

Hi,

I have been told by the Experts that to hide the row containing zeros or blanks, I can filter and then the remaining cells can be copies to another sheet by Edit Copy –new sheet - Edit Paste special – visible cells only.

A macro for the above would be most appreciated.

If Zero or blank cell is found from G12 - G65536, then the those rows to be hidden. The visible cells only to be transferred to a new sheet.

I am using Windows 98 & Office 2000
Best Regards,


Shan
Excel-ent is offline   Reply With Quote
Old Mar 30th, 2004, 06:15 AM   #2
Zack Barresse
MrExcel MVP
 
Zack Barresse's Avatar
 
Join Date: Dec 2003
Location: Oregon, USA
Posts: 9,551
Default

hi Shan,

how about recording a macro? this will make your desired code for you.

i would do an advanced filter for anything greater than zero, go to (F5) visible cells only (as you stated), copy, navigate, paste special (values, formats, formulas, choose your poison).

you can then see your relevant code by pressing Alt + F11 (shortcut to the Visual Basic Editor), finding your workbook, and looking in the Modules folder (left frame, code in right frame).

hth
__________________
Regards,
Zack Barresse

All Excel Functions
(If you would like comments in any code, please say so.)
Zack Barresse is offline   Reply With Quote
Old Mar 31st, 2004, 01:23 AM   #3
erik.van.geit
MrExcel MVP
 
erik.van.geit's Avatar
 
Join Date: Mar 2004
Location: Belgium 3272 Testelt
Posts: 16,771
Default Re: Hiding Rows

Hello,
found in archives
don't know the original author
I changed it a bit

This macro will hide all of the blank rows in the active worksheet or in the selection if covering more than one row.

Code:
Public Sub HideBlankRows()

Dim R As Long
Dim C As Range
Dim n As Long
Dim rng As Range

On Error GoTo EndMacro
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual

If Selection.Rows.Count > 1 Then
Set rng = Selection
Else
Set rng = ActiveSheet.UsedRange.Rows
End If
n = 0
For R = rng.Rows.Count To 1 Step -1
MsgBox R & " " & Application.WorksheetFunction.CountA(rng.Rows(R).EntireRow)
If Application.WorksheetFunction.CountA(rng.Rows(R).EntireRow) = 0 Then
rng.Rows(R).EntireRow.Hidden = True
n = n + 1
End If
Next R

EndMacro:

Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic

End Sub
regards,
Erik
__________________
I love Jesus
calm down piano improvisation

email Erik

founder of DRAFT

my free Addins
Table-It download & info
Formula Translator 03
erik.van.geit is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


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


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
All contents Copyright 1998-2009 by MrExcel Consulting.