PDA

View Full Version : Hide Rows based on variable



Kindly_Kaela
12-28-2006, 02:11 PM
I'm trying to hide rows in excel based on a VBA variable. The variable in my program is Days. Can someone help me make this work. This is what I tried...

Public Days As Single
Rows(Days:368).Select
Selection.EntireRow.Hidden = True


I'm confident Days is working as a variable, because I tested it with:
MsgBox Days

Thank you,
Kaela
:cloud9:

Norie
12-28-2006, 02:32 PM
Kaela

Days may be 'working' as a variable but you aren't using it correctly.

Try this, untested, code.

Public Days As Single
Rows(Days & ":368").EntireRow.Hidden = True

PS Where are you actually giving Days a value?

Zack Barresse
12-28-2006, 02:37 PM
Kaela,

Can you post your code in its entirety and explain what it is that you are trying to accomplish?

a

Bob Phillips
12-28-2006, 02:37 PM
Best to make it a Long variable, and EntireRow is redundant



Public Days As Long


Rows(Days & ":368").Hidden = True