Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Catherine Bond
 
Posts: n/a
Default How to code Macro for hiding rows

Hello!

I need help with some macro coding, as I am new to it.

Here is the basic breakdown:
I have 50 rows of data space.
Some rows do not have date.
I need to hide the rows which don't have data.
If I could code it by dictation, I would say "If A2 is empty, hide the row.
Do the same for A3 through A50"

Any suggestions??
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Norman Jones
 
Posts: n/a
Default How to code Macro for hiding rows

Hi Catherine,

Try:

'=============
Public Sub Tester()
Dim rng As Range

Set rng = ActiveSheet.Range("A2:A50") '<<==== CHANGE

On Error Resume Next
rng.SpecialCells(xlBlanks).EntireRow.Delete
On Error GoTo 0

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


---
Regards,
Norman


"Catherine Bond" wrote in message
...
Hello!

I need help with some macro coding, as I am new to it.

Here is the basic breakdown:
I have 50 rows of data space.
Some rows do not have date.
I need to hide the rows which don't have data.
If I could code it by dictation, I would say "If A2 is empty, hide the
row.
Do the same for A3 through A50"

Any suggestions??



  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Norman Jones
 
Posts: n/a
Default How to code Macro for hiding rows

Hi Catherine,

As you are not familiar with macros, you may wish to visit David McRitchie's
'Getting Started With Macros And User Defined Functions' at:

http://www.mvps.org/dmcritchie/excel/getstarted.htm

You might also look at David's tutorials page at:

http://www.mvps.org/dmcritchie/excel....htm#tutorials

The VBA tutorial information is towards the end of that section.


---
Regards,
Norman


  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Norman Jones
 
Posts: n/a
Default How to code Macro for hiding rows

Hi Catherine,

rng.SpecialCells(xlBlanks).EntireRow.Delete


Should read:

rng.SpecialCells(xlBlanks).EntireRow.Hidden = True



The first (erroneously) deletes the blank rows; the second hides these rows,
as you requested!


---
Regards,
Norman



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

Try:

'=============
Public Sub Tester()
Dim rng As Range

Set rng = ActiveSheet.Range("A2:A50") '<<==== CHANGE

On Error Resume Next
rng.SpecialCells(xlBlanks).EntireRow.Delete
On Error GoTo 0

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


---
Regards,
Norman



  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Trevor Shuttleworth
 
Posts: n/a
Default How to code Macro for hiding rows

One way:

Sub HideRows()
Dim i As Long
Application.ScreenUpdating = False
For i = 2 To 50
If Range("A" & i).Value = "" Then
Range("A" & i).EntireRow.Hidden = True
End If
Next 'i
Application.ScreenUpdating = True
End Sub

Regards

Trevor


"Catherine Bond" wrote in message
...
Hello!

I need help with some macro coding, as I am new to it.

Here is the basic breakdown:
I have 50 rows of data space.
Some rows do not have date.
I need to hide the rows which don't have data.
If I could code it by dictation, I would say "If A2 is empty, hide the
row.
Do the same for A3 through A50"

Any suggestions??





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
Macro to: Find a Reference, and then Paste into the 10 Rows Below Blobbies Excel Discussion (Misc queries) 9 March 14th 06 11:17 AM
macro or code to open multiple workbooks Duane Reynolds Excel Discussion (Misc queries) 1 March 14th 06 08:18 AM
How to see macro code of a password protected macro without a password? Dmitry Kopnichev Excel Worksheet Functions 5 October 27th 05 09:57 AM
Macro as multiple use code Bruce Neylon New Users to Excel 6 June 29th 05 06:11 PM
Make Change Case in Excel a format rather than formula Kevin Excel Worksheet Functions 1 March 18th 05 08:53 PM


All times are GMT +1. The time now is 11:24 PM.

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"