Alternative way to refer to a row to hide or unhide...

  • Thread starter Thread starter Darin Kramer
  • Start date Start date
D

Darin Kramer

Hi There,

I currently have a simple VB that selects data in row 60 and 61 (see
below). Problem is that if a user adds lines (and its quite possible
that he may) the macro will not hide the correct row. Is there VB to
hide a named range...?

Kind regards

Darin

Rows("60:61").Select
Selection.EntireRow.Hidden = True
 
Select the rows you want hidden, click in the address window (upper left of
sheet where you see the cell reference). Type a name in that window to give
the selected rows a "Named Range". Then put that name in your code in place
of the rows reference. This way, when rows are added above, the named range
will remain constant.
 
Assign a Named Range to the rows and use the name:



Sub demo()
Range("ready_for_hide").EntireRow.Hidden = True
End Sub




The named cells will adjust as rows are added or deleted.
 

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

Hide and Unhide Rows button 6
Hiding and unhiding rows 8
Hide Rows Using Checkbox 3
hide & unhide toggle button 3
Hidden Rows not working correctly 2
Macro to Unhide Rows 3
hide/unhide macro 2
Hide, unhide macro 19

Back
Top