A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Excel » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Macro for hiding rows



 
 
Thread Tools Display Modes
  #1  
Old December 23rd, 2005, 09:48 AM posted to microsoft.public.excel.misc
external usenet poster
 
Posts: n/a
Default Macro for hiding rows

I have a spreadsheet which contains a lot of rows with no data, I would like
to create a macro to hide these rows.

Preferably I would like it to work off one column and hide any rows with a
value of zero.

Any ideas?
  #2  
Old December 23rd, 2005, 10:28 AM posted to microsoft.public.excel.misc
external usenet poster
 
Posts: n/a
Default Macro for hiding rows

I think, that no macro is necessary to to this job! Simply apply an
Autofilter and choose Not empty when clicking the drop-down arrow!

Regards,
Stefi


„Luke” ezt *rta:

I have a spreadsheet which contains a lot of rows with no data, I would like
to create a macro to hide these rows.

Preferably I would like it to work off one column and hide any rows with a
value of zero.

Any ideas?

  #3  
Old December 23rd, 2005, 10:36 AM posted to microsoft.public.excel.misc
external usenet poster
 
Posts: n/a
Default Macro for hiding rows

Luke,

try this VBA code: (this code consider the name of the sheet as Sheet1 and
you want to hide the rows that the cell in the column A is empty)

Sub HideEmptyRows()

With Worksheets("Sheet1")

lastrow = .Range("A65536").End(xlUp).Row

For i = 1 To lastrow

If .Range("A" & i).Value = "" Then

Rows(i & ":" & i).EntireRow.Hidden = True

End If

Next i

End With

End Sub

i hope this can help you!

Have a nice Christmas end a great New Year!

Pedro

"Luke" wrote:

I have a spreadsheet which contains a lot of rows with no data, I would like
to create a macro to hide these rows.

Preferably I would like it to work off one column and hide any rows with a
value of zero.

Any ideas?

  #4  
Old December 23rd, 2005, 10:54 AM posted to microsoft.public.excel.misc
external usenet poster
 
Posts: n/a
Default Macro for hiding rows

another way without macros:

1) select one of the columns where empty cells correspond to empty rows
2) menu EditGoto...
3) press the button 'Special...'
4) mark the 'Blanks' option and press 'OK'
5) menu FormatRowsHide...

or using short cut keys:

1) having the cursor in a cell of the relevant column press Ctrl+Space
2) Ctrl+g
3) Hold Alt+ s, k,
4) Enter
5) Hold Alt + o, r, h

Regards,
KL


"Luke" wrote in message ...
I have a spreadsheet which contains a lot of rows with no data, I would like
to create a macro to hide these rows.

Preferably I would like it to work off one column and hide any rows with a
value of zero.

Any ideas?

  #5  
Old December 23rd, 2005, 10:58 AM posted to microsoft.public.excel.misc
external usenet poster
 
Posts: n/a
Default Macro for hiding rows


it is looking easy to hide blank cell rows rather containing zero value
while i exercise on your point you may try the following for hiding the
blank cell rows
Ctrl+G (Go To Command) or Edit I Go To I
Select Special
Select Blank
Enter or Click OK
The above process/commands selects all bank cells. Then
Format I Row I Hide


--
gandhi318Posted from - http://www.officehelp.in

  #6  
Old December 23rd, 2005, 10:58 AM posted to microsoft.public.excel.misc
external usenet poster
 
Posts: n/a
Default Macro for hiding rows

Hi Luke,

As an alternative, try:

Try:

'=============
Public Sub Tester()

On Error Resume Next
Columns(2).SpecialCells(xlCellTypeBlanks).EntireRo w.Delete
On Error GoTo 0

End Sub
'=============


---
Regards,
Norman


"Luke" wrote in message
...
I have a spreadsheet which contains a lot of rows with no data, I would
like
to create a macro to hide these rows.

Preferably I would like it to work off one column and hide any rows with a
value of zero.

Any ideas?



  #7  
Old December 23rd, 2005, 11:04 AM posted to microsoft.public.excel.misc
external usenet poster
 
Posts: n/a
Default Macro for hiding rows

Hi Luke:

Columns(2).SpecialCells(xlCellTypeBlanks).EntireRo w.Delete


Was intended to read::

Columns(1).SpecialCells(xlCellTypeBlanks).EntireRo w.Delete

---
Regards,
Norman


"Norman Jones" wrote in message
...
Hi Luke,

As an alternative, try:

Try:

'=============
Public Sub Tester()

On Error Resume Next
Columns(2).SpecialCells(xlCellTypeBlanks).EntireRo w.Delete
On Error GoTo 0

End Sub
'=============


---
Regards,
Norman


"Luke" wrote in message
...
I have a spreadsheet which contains a lot of rows with no data, I would
like
to create a macro to hide these rows.

Preferably I would like it to work off one column and hide any rows with
a
value of zero.

Any ideas?





  #8  
Old December 23rd, 2005, 11:22 AM posted to microsoft.public.excel.misc
external usenet poster
 
Posts: n/a
Default Macro for hiding rows


Sir
your suggested micro is not working
please check yourself and see a revised one is suggested
you may see my reply which hides emptry cell rows









PedroPastre Wrote:
Luke,

try this VBA code: (this code consider the name of the sheet as Sheet1
and
you want to hide the rows that the cell in the column A is empty)

Sub HideEmptyRows()

With Worksheets("Sheet1")

lastrow = .Range("A65536").End(xlUp).Row

For i = 1 To lastrow

If .Range("A" & i).Value = "" Then

Rows(i & ":" & i).EntireRow.Hidden = True

End If

Next i

End With

End Sub

i hope this can help you!

Have a nice Christmas end a great New Year!

Pedro

"Luke" wrote:

I have a spreadsheet which contains a lot of rows with no data, I

would like
to create a macro to hide these rows.

Preferably I would like it to work off one column and hide any rows

with a
value of zero.

Any ideas?



--
gandhi318Posted from - http://www.officehelp.in

  #9  
Old December 23rd, 2005, 11:22 AM posted to microsoft.public.excel.misc
external usenet poster
 
Posts: n/a
Default Macro for hiding rows

just to add two comments:

1) I guess the task is to hide not to delete, so probably:
Columns(2).SpecialCells(xlCellTypeBlanks).EntireRo w.Hidden=True

2) This method has a limitation of max 8,192 non-contiguous cells (otherwise it includes the whole column/row/sheet):
http://support.microsoft.com/kb/832293/en-us For this to become an issue in this specific example one needs to have at least 16385
rows where every other row is blank (so the risk might be remote).

Regards,
KL


"Norman Jones" wrote in message ...
Hi Luke,

As an alternative, try:

Try:

'=============
Public Sub Tester()

On Error Resume Next
Columns(2).SpecialCells(xlCellTypeBlanks).EntireRo w.Delete
On Error GoTo 0

End Sub
'=============


---
Regards,
Norman


"Luke" wrote in message ...
I have a spreadsheet which contains a lot of rows with no data, I would like
to create a macro to hide these rows.

Preferably I would like it to work off one column and hide any rows with a
value of zero.

Any ideas?




  #10  
Old December 23rd, 2005, 12:15 PM posted to microsoft.public.excel.misc
external usenet poster
 
Posts: n/a
Default Macro for hiding rows

Hi,

your suggested micro is not working


What do you mean it "is not working"? Can you please be more specific? It does to me, only it is slow, blinking and may need some
optimization. Perhaps:

Sub HideEmptyRows()
Application.ScreenUpdating=False
With Worksheets("Sheet1")
lastrow = .Range("A65536").End(xlUp).Row
For i = 1 To lastrow
If .Range("A" & i).Value = "" Then
Rows(i ).EntireRow.Hidden = True
End If
Next i
End With
Application.ScreenUpdating=True
End Sub

Also if there is a significant number of rows I would use the SpecialCells one (see the the reply by Norman Jones) as it is way
faster.

please check yourself and see a revised one is suggested


You can guess...;-)

Regards,
KL

 




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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro Help In Excel welshlad General Discussion 14 October 26th, 2005 02:34 PM
Closing File Error jcliquidtension General Discussion 4 October 20th, 2005 12:22 PM
macro to add rows and copy and paste Steve Worksheet Functions 9 June 4th, 2004 06:14 PM
macro to add rows and copy data into the rows Steve Worksheet Functions 2 June 3rd, 2004 08:50 PM
Counting Rows in Excel Macro Randy Wiseman Worksheet Functions 1 December 14th, 2003 02:13 PM


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


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright 2004-2024 OfficeFrustration.
The comments are property of their posters.