Hide Multiple Rows

Partjob

Board Regular
Joined
Apr 17, 2008
Messages
139
Hi Everybody
I seem to have a simple problem but can't get it right.
I am trying to hide Rows with multiple ranges.
I recorded this to see how to structure such a statement.
Code:
Range("7:12,22:28").EntireRow.Hidden = True
This works obviously however the following doesn't and I don't understand why.
Code:
Sheet6.Range(StrRowP & ":" & 38,StrRowC & ":" & 280,StrRowE & ":" & 408).EntireRow.Hidden = True

Can you list multiple ranges like this or because I have varibles in the range do I have to write them individually. Could you also please explain what rules I have to follow for such a situation.

Thanks for the help
Partjob
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Look Very Carefully at how your range string is being built.

Try

Sheet6.Range(StrRowP & ":38, " & StrRowC & ":280, " & StrRowE & ":408").EntireRow.Hidden = True
 
Upvote 0
Jonmo
Thanks a lot, just to clarify, I must enclose all parts of the string in inverted commas including the commas that seperate the ranges themselves, but excluding the varables. I take it this would be the same for any multiple range string?
I would never have guessed that.
Thanks
Partjob
 
Upvote 0
Just keep in mind that you're building the command using concatenate.

combining text strings with variables.

The TEXT STRINGS should be within Quotes. The VARIABLES Should NOT be in quotes.

Example

Variable1 = 75
Variable2 = 38

I want my formula to read
=IF(A38=A75,100,0)

to build that i use
Range("a1").Formula = "=IF(A" & Variable2 & "=A" & Variable1 & ",100,0)"

"=IF(A" <---This is the first Text String (surrounded by quotes)
& Variable2 <---Concatenates Variable 2
& "=A" <---Concatenates the next text string "=A" (surrounded by quotes)
& Variable1 <----Concatenates Variable 1
& ",100,0)" <---Concatenages the last text string ",100,0)" (surrounded by quotes)
 
Upvote 0
Jonmo
Great explaination and I do understand, the clues were there really in the bit I recorded, I just did not see them. I have also built formulas in the very way you have just explained but did not associate that with what I was trying to do.

all the best

Partjob
 
Upvote 0

Forum statistics

Threads
1,216,099
Messages
6,128,823
Members
449,470
Latest member
Subhash Chand

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