Defining Ranges Using VBA

sunny123

New member
Joined
Feb 1, 2013
Messages
1
Reaction score
0
Points
0
Hello Friends,

I am new to to VB does have only vague idea about it..

Private Sub CommandButton1_Click()
Range(Range("a1").End(xlDown).Offset(1, 0), Range("a" & Rows.Count)).EntireRow.Hidden = True
End Sub

Private Sub CommandButton1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
Range(Range("a1"), Range("a" & Rows.Count)).EntireRow.Hidden = False
End Sub

I have a macro enabled book with a button to hide and unhide rows,but the
problem with this code is it is hiding the entire blank "a" rows,i dont need like that just need to specify a range like A1:A50,i tried to change but it gives me a debug error..

Regards,
Sunny
 

Bob Phillips

Super Moderator
Staff member
Joined
Mar 21, 2011
Messages
1,940
Reaction score
0
Points
36
Excel Version(s)
O365
What is wrong with

Code:
Rows("1:50").Hidden = True
 
Top