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.
 

Some videos you may like

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number

John92

New Member
Joined
Sep 15, 2014
Messages
4
Are you trying to hide rows based on a value?

Yes I'm trying to hide a qty of rows, based on a value.
This can depend from row 5:25 up until 25:25. The first value I have located in a cell. therefore I want to look up this value.
 

John92

New Member
Joined
Sep 15, 2014
Messages
4

ADVERTISEMENT

Try:

Code:
Rows(Range(E1).Value & ":25").EntireRow.Hidden = False

Many thanks for your answer. I tried it, unfortunately I get a

Run-time error '1004'
Method 'Range' of object '_Global' failed


Gr.
john.
 

Rick Rothstein

MrExcel MVP
Joined
Apr 18, 2011
Messages
36,720
Office Version
  1. 2010
Platform
  1. Windows
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:

Watch MrExcel Video

Forum statistics

Threads
1,123,481
Messages
5,601,918
Members
414,482
Latest member
morkar

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
Top