-
Hide Rows based on variable
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
-
Kaela
Days may be 'working' as a variable but you aren't using it correctly.
Try this, untested, code.
[vba]
Public Days As Single
Rows(Days & ":368").EntireRow.Hidden = True
[/vba]
PS Where are you actually giving Days a value?
-
Kaela,
Can you post your code in its entirety and explain what it is that you are trying to accomplish?
[uvba]a[/uvba]
-
Best to make it a Long variable, and EntireRow is redundant
[vba]
Public Days As Long
Rows(Days & ":368").Hidden = True
[/vba]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules