VBA try to hide rows

John92

New Member
Joined
Sep 15, 2014
Messages
4
Dear friends,
I try to hide a # of rows from cell value (E1) .. 21
therefore I wrote

Rows("(Range(E1).value):25").EntireRow.Hidden = False

(in my case Cell (E1) = 10, but can vary in value.
Obviously there is a type mismatch. What do I do wrong here?

Many thanks for your replies.
Highly appreciated.

Gr.
john.
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
Many thanks for your answer. I tried it, unfortunately I get a

Run-time error '1004'
Method 'Range' of object '_Global' failed
Andrew has a typo in his code... he omitted the quote marks that are required by the Range object around its argument (the E1 address in this case)...

Code:
Rows(Range([COLOR=#ff0000][B]"[/B][/COLOR]E1[COLOR=#ff0000][B]"[/B][/COLOR]).Value & ":25").Hidden = True

Note that I removed the EntireRow property which is not needed because Rows was specified as the Range object. I will also point out, if the address where the value is being taken from (the E1 address) is fixed and unchanging, then there is a more compact form of this code line...

Code:
Rows([E1] & ":25").Hidden = True

Note, with the square bracket notation, and because the address is fixed, quote marks are not used around the E1 address.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,213,536
Messages
6,114,208
Members
448,554
Latest member
Gleisner2

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