How to code Macro for hiding rows

G

Guest

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??
 
N

Norman Jones

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
'<<=============
 
T

Trevor Shuttleworth

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top