PC Review


Reply
Thread Tools Rate Thread

Code to hide and unhide cells (SC).

 
 
sreeram.i.c@gmail.com
Guest
Posts: n/a
 
      31st Mar 2007
I'm designing a form where Cell A5, which is named Off_Num. This cell
has Values (Select One, 1 to 20) in a dropdown, and Rows 9 to 28 are
hidden.

Now if 1 is selected in Off_Num cell then, the code should Unhide Row
9. And if 2 is selected then Row(9:10) should be unhidden so on, till
if 20 is selected the Rows(9:28) should be unhidden. And if Select One
option is selected that Rows(9:28) should get hidden again.

Please help me with this.

 
Reply With Quote
 
 
 
 
JE McGimpsey
Guest
Posts: n/a
 
      31st Mar 2007
One way:

Put this in your worksheet code module:

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
With Range("Off_Num")
If Not Intersect(.Cells, Target) Is Nothing Then
Application.ScreenUpdating = False
Rows("9:28").Hidden = True
If IsNumeric(.Value) Then
Rows("9:9").Resize(CLng(.Value)).Hidden = False
End If
Application.ScreenUpdating = True
End If
End With
End Sub


In article <(E-Mail Removed)>,
(E-Mail Removed) wrote:

> I'm designing a form where Cell A5, which is named Off_Num. This cell
> has Values (Select One, 1 to 20) in a dropdown, and Rows 9 to 28 are
> hidden.
>
> Now if 1 is selected in Off_Num cell then, the code should Unhide Row
> 9. And if 2 is selected then Row(9:10) should be unhidden so on, till
> if 20 is selected the Rows(9:28) should be unhidden. And if Select One
> option is selected that Rows(9:28) should get hidden again.
>
> Please help me with this.

 
Reply With Quote
 
sreeram.i.c@gmail.com
Guest
Posts: n/a
 
      31st Mar 2007
On Mar 31, 7:06 pm, JE McGimpsey <jemcgimp...@mvps.org> wrote:
> One way:
>
> Put this in your worksheet code module:
>
> Private Sub Worksheet_Change(ByVal Target As Excel.Range)
> With Range("Off_Num")
> If Not Intersect(.Cells, Target) Is Nothing Then
> Application.ScreenUpdating = False
> Rows("9:28").Hidden = True
> If IsNumeric(.Value) Then
> Rows("9:9").Resize(CLng(.Value)).Hidden = False
> End If
> Application.ScreenUpdating = True
> End If
> End With
> End Sub
>
> In article <1175337624.979491.56...@o5g2000hsb.googlegroups.com>,
>
>
>
> sreeram....@gmail.com wrote:
> > I'm designing a form where Cell A5, which is named Off_Num. This cell
> > has Values (Select One, 1 to 20) in a dropdown, and Rows 9 to 28 are
> > hidden.

>
> > Now if 1 is selected in Off_Num cell then, the code should Unhide Row
> > 9. And if 2 is selected then Row(9:10) should be unhidden so on, till
> > if 20 is selected the Rows(9:28) should be unhidden. And if Select One
> > option is selected that Rows(9:28) should get hidden again.

>
> > Please help me with this.- Hide quoted text -

>
> - Show quoted text -


Thanks a lot this works just as i wanted.

 
Reply With Quote
 
Ram
Guest
Posts: n/a
 
      1st Apr 2007
On Mar 31, 10:53 pm, sreeram....@gmail.com wrote:
> On Mar 31, 7:06 pm, JE McGimpsey <jemcgimp...@mvps.org> wrote:
>
>
>
>
>
> > One way:

>
> > Put this in your worksheet code module:

>
> > Private Sub Worksheet_Change(ByVal Target As Excel.Range)
> > With Range("Off_Num")
> > If Not Intersect(.Cells, Target) Is Nothing Then
> > Application.ScreenUpdating = False
> > Rows("9:28").Hidden = True
> > If IsNumeric(.Value) Then
> > Rows("9:9").Resize(CLng(.Value)).Hidden = False
> > End If
> > Application.ScreenUpdating = True
> > End If
> > End With
> > End Sub

>
> > In article <1175337624.979491.56...@o5g2000hsb.googlegroups.com>,

>
> > sreeram....@gmail.com wrote:
> > > I'm designing a form where Cell A5, which is named Off_Num. This cell
> > > has Values (Select One, 1 to 20) in a dropdown, and Rows 9 to 28 are
> > > hidden.

>
> > > Now if 1 is selected in Off_Num cell then, the code should Unhide Row
> > > 9. And if 2 is selected then Row(9:10) should be unhidden so on, till
> > > if 20 is selected the Rows(9:28) should be unhidden. And if Select One
> > > option is selected that Rows(9:28) should get hidden again.

>
> > > Please help me with this.- Hide quoted text -

>
> > - Show quoted text -

>
> Thanks a lot this works just as i wanted.- Hide quoted text -
>
> - Show quoted text -


Now i am back with another question

How can i write the same code if i have to unhide a set of rows
instead of a single row. Similar to above, if 1 is selected in cell
Mod_Num then rows (5 to 10) should get unhidden and in 2 is selected
rows (5 to 15) will get unhidden so on till i enter 5 to unhide the
entire range of rows that are hidden. is this possible??
Thanks for your help.

 
Reply With Quote
 
Norman Jones
Guest
Posts: n/a
 
      1st Apr 2007
Hi Ram,

See at least one response il your later thread.


---
Regards,
Norman



"Ram" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> On Mar 31, 10:53 pm, sreeram....@gmail.com wrote:
>> On Mar 31, 7:06 pm, JE McGimpsey <jemcgimp...@mvps.org> wrote:
>>
>>
>>
>>
>>
>> > One way:

>>
>> > Put this in your worksheet code module:

>>
>> > Private Sub Worksheet_Change(ByVal Target As Excel.Range)
>> > With Range("Off_Num")
>> > If Not Intersect(.Cells, Target) Is Nothing Then
>> > Application.ScreenUpdating = False
>> > Rows("9:28").Hidden = True
>> > If IsNumeric(.Value) Then
>> > Rows("9:9").Resize(CLng(.Value)).Hidden = False
>> > End If
>> > Application.ScreenUpdating = True
>> > End If
>> > End With
>> > End Sub

>>
>> > In article <1175337624.979491.56...@o5g2000hsb.googlegroups.com>,

>>
>> > sreeram....@gmail.com wrote:
>> > > I'm designing a form where Cell A5, which is named Off_Num. This cell
>> > > has Values (Select One, 1 to 20) in a dropdown, and Rows 9 to 28 are
>> > > hidden.

>>
>> > > Now if 1 is selected in Off_Num cell then, the code should Unhide Row
>> > > 9. And if 2 is selected then Row(9:10) should be unhidden so on, till
>> > > if 20 is selected the Rows(9:28) should be unhidden. And if Select
>> > > One
>> > > option is selected that Rows(9:28) should get hidden again.

>>
>> > > Please help me with this.- Hide quoted text -

>>
>> > - Show quoted text -

>>
>> Thanks a lot this works just as i wanted.- Hide quoted text -
>>
>> - Show quoted text -

>
> Now i am back with another question
>
> How can i write the same code if i have to unhide a set of rows
> instead of a single row. Similar to above, if 1 is selected in cell
> Mod_Num then rows (5 to 10) should get unhidden and in 2 is selected
> rows (5 to 15) will get unhidden so on till i enter 5 to unhide the
> entire range of rows that are hidden. is this possible??
> Thanks for your help.
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
RE: code to hide/unhide rows ryguy7272 Microsoft Excel Programming 0 29th May 2009 02:44 AM
Hide and unhide shaded cells Sylve Microsoft Excel New Users 12 8th Mar 2009 09:09 PM
Question on Hide/Unhide cells Thulasiram Microsoft Excel Programming 4 26th Jul 2006 11:21 PM
Hide/Unhide cells using VBA programming =?Utf-8?B?VGh1bGFzaXJhbQ==?= Microsoft Excel Programming 3 21st Jul 2006 11:12 PM
hide/unhide cells =?Utf-8?B?Z2FycGF2Y28=?= Microsoft Excel Worksheet Functions 3 13th Jan 2005 01:33 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:04 PM.