auto-hide & Auto-fit rows?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I've tried a couple macro's I've seen online, but I can't seem to make a
macro work to hide lines on my worksheet.

I've got a quote worksheet with rows 13:130 available for quoting.

In column A is where the quantity gets filled in automatically from a
previous tab via a macro.

I'd like this worksheet to automatically hid the any rows on this tab that
do not have a quantity in column A.

Also, I've got my worksheet o "Auto-fit" the rows in this worksheet and the
worksheet that feeds information into it via a Macro to "Auto-Fit" rows to
the description of the product, however it doesn't happen. Any idea what I
should do here?

Many thanks!
 
Nango, see if any of this works and Ill try to explain myself as I go along.

Sub HideRows()
Range("A13").Activate

Do Until ActiveCell.Rows.Count = 130

If IsEmpty(ActiveCell) Then
Selection.EntireRow.Hidden = True
ActiveCell.Offset(1,0).Activate

Else: ActiveCell.Offset(1,0).Activate
End If
Loop

End Sub

This sub will go through rows 13-130 every time and hide any row that
doesn't have a value. If you want to hide all the cells after that... add
something like this

Range(Range("A131"),Range("A131").End(xlDown).Hidden = True

LMK what else you need
 
Thanks for the help. The only problem is this seems to be going through
every row in the entire workbook

Sub HideRows()
Range("A13").Activate

Do Until ActiveCell.Rows.Count = 130

If IsEmpty(ActiveCell) Then
Selection.EntireRow.Hidden = True
ActiveCell.Offset(1,0).Activate

Else: ActiveCell.Offset(1,0).Activate
End If
Loop

End Sub

Any ideas?
 
Alright change this line

Do Until ActiveCell.Rows.Count = 130

to

Do Until ActiveCell.Address = "$A$131"

Sorry
 
Alright, don't touch anything, just copy and paste this exactly as shown in
to a regular module.

Go to the VBE and go to Insert---> Module
And then paste this in to it.

Sub HideRows()

Range("A13").Activate

Do Until ActiveCell.Address = "$A$131"

If IsEmpty(ActiveCell) Then
Selection.EntireRow.Hidden = True

ActiveCell.Offset(1,0).Activate

Else: ActiveCell.Offset(1,0).Activate
End If
Loop

End Sub
 
I'll let you go for now. I'm not sure what I'm doing wrong. Except this is
the first time I've ever tried VBE and I've never gotten even a simple macro
to work.

Sorry to take so much time.

Thank you very much for all your help.
 
No problem, glad to help. I'm actually in Prudhoe Bay right now working on an
oil field as a financial analyst. We work 12-15 hour days, 7 days a week...
so I have a lot of free time on my hands, lol. Have a good one.
 
Back
Top