Running A Macro for Specific Rows Only

TJC86

New Member
Joined
Aug 27, 2014
Messages
17
Hi,

I'm sure this is really simple but I can't figure it out for the life of me. I have the following Macro:

Sub UnhideRow1()
Dim i As Long
If columns("A").SpecialCells(xlCellTypeVisible).Count = rows.Count Then Exit Sub
i = 1
Do Until rows(i).Hidden = True
i = i + 1
Loop
rows(i).Hidden = False
End Sub


It works okay, but I only want it to work for rows 50:77 as I have hidden rows after that which I don't want to unhide.

How can I limit the macro to run just for these rows. I've been all over Google and can't get it to work.

Thank you!!
 
Last edited:
That works perfectly, thank you!

You've done in 2 minutes what has taken me 4 hours to get nowhere with. Amazing.

My hero.
 
Upvote 0

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Okay, give this macro a try...
Code:
Sub ShowFirstHiddenRow()
  If Rows(50).Hidden Then
    Rows(50).Hidden = False
  Else
    On Error Resume Next
    With Range("A49:A77").SpecialCells(xlVisible)
      .Areas(1)(.Areas(1).Count).Offset(1).EntireRow.Hidden = False
    End With
    On Error GoTo 0
  End If
End Sub

Hey sorry to drag up an old thread. Your code is awesome and works perfectly! I was wondering is there a way to un-hide two rows at a time using this same method?

*First time posting so not sure if this is the right thing to do or not*

Thanks
 
Upvote 0
Hey sorry to drag up an old thread. Your code is awesome and works perfectly! I was wondering is there a way to un-hide two rows at a time using this same method?

*First time posting so not sure if this is the right thing to do or not*
Your question is not really a follow-up to the one that started this thread, so I think starting a new thread with your question will give you the widest audience of volunteers to help answer it. When you do post your new thread, be sure to explain fully what you want... I am not exactly sure what you are after when you say "unhide two rows at a time"... at what time? Remember when you post your question, the people you are seeking help from know absolutely nothing about you data, how it is laid out, what you want to do with it, what results you expect to get from whatever solutions we give you or where you want those solutions to go to or appear at... you have to make sure your question provides enough details so that we don't have to guess at any of those items I just listed. Screenshots help (see my signature line for one way to provide them).
 
Upvote 0
Your question is not really a follow-up to the one that started this thread, so I think starting a new thread with your question will give you the widest audience of volunteers to help answer it. When you do post your new thread, be sure to explain fully what you want... I am not exactly sure what you are after when you say "unhide two rows at a time"... at what time? Remember when you post your question, the people you are seeking help from know absolutely nothing about you data, how it is laid out, what you want to do with it, what results you expect to get from whatever solutions we give you or where you want those solutions to go to or appear at... you have to make sure your question provides enough details so that we don't have to guess at any of those items I just listed. Screenshots help (see my signature line for one way to provide them).

Hey thanks for your response! Yeah will try to provide as much info as I can in the future my apologies for that.

I'm not very proficient with VBA so I do apologise if the terms I use to describe functions are incorrect. With the solution you provided it goes through and just un-hides the next row that is hidden. So per your example it starts at 50 and says if 50 is hidden then unhide it else go to 51 and so on. This is only Un-Hiding one row at a time. I would like to know if it is possible to un-hide two rows at a time. So starting at 50 per your example again if 50 is hidden unhide 50+51.

Does that make sense?

Thanks again for responding!

Regards
 
Upvote 0

Forum statistics

Threads
1,223,104
Messages
6,170,125
Members
452,303
Latest member
c4cstore

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top