PDA

View Full Version : Defining Ranges Using VBA



sunny123
01-31-2013, 10:04 PM
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

xld
02-01-2013, 09:16 AM
Cross-posted at XLGuru http://www.excelguru.ca/forums/showthread.php?1448-Defining-Ranges-Using-VBA