VB Code to hide and unhide rows

ateebali

Board Regular
Joined
Dec 13, 2018
Messages
108
Dear Sir
Using following code;

Sub Macro1()
'
' Macro1 Macro
'


'
Range("A7:A8").Select
Selection.EntireRow.Hidden = False


End Sub

It is linked with button, when I click it, its Unhide the rows A7:A8
I need to write the code then when we click again, it should hide A10:A11
then when click again it should hide A13:A14
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Dear Sir
I am sorry to bother you again, I have changed the area from A5:A250 TO A5:A498 but the code is not working now, please help again;

Sub addrow()

Dim Ar As Areas
Set Ar = Range("A5:498").SpecialCells(xlVisible).Areas
Ar(Ar.Count).Offset(4).Resize(2).EntireRow.Hidden = False


End Sub
 
Upvote 0
Compare your description to the code you posted & you should see the problem.

Alos please use code tags, the # icon, when posting code. Not quotes.
 
Upvote 0
Dear Sir,
I am sorry I am zero in VB, i need your help to identify the problem, this error is appearing;
Run Time Error 1004
Method 'Range' of object '-Global" failed
Code:
 Set Ar = Range("A5:498").SpecialCells(xlVisible).Areas
 
Last edited:
Upvote 0
Simply compare that line of code to this description that you gave
I have changed the area from A5:A250 TO A5:A498
Can you spot the difference?
 
Upvote 0
Yes sir because the range increase
I have changed range from a5:a250 to a5:a498
Same i changed to other codes of unhide rows and also to clear cell code and its working fine
I need help please
 
Upvote 0
Whilst I am more than willing to help,I am not going to just spoon feed you all the time.
That means that you need to do some of the work.
What I am asking you to do is look at the code in post#34, compare it to the description that you have given & try and spot the obvious difference between the two.
 
Upvote 0
Yes sir because the range increase
I have changed range from a5:a250 to a5:a498
Same i changed to other codes of unhide rows and also to clear cell code and its working fine
I need help please
you deleted the second A excel has no idea about that. 1004 generally mean something is missing, and as it came after your code change you need to start there
 
Upvote 0

Forum statistics

Threads
1,214,587
Messages
6,120,406
Members
448,958
Latest member
Hat4Life

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