PC Review


Reply
Thread Tools Rate Thread

Code correction pls help

 
 
Ram
Guest
Posts: n/a
 
      16th Aug 2007
Hi,

I have a cell (D4) in Sheet 2, which is referenced to cell (D87) in
Sheet1.

Cell D4 has a dropdown (thru Data -> Validation -> list) Values are :-
Select one, 1, 2, 3, 4, 5

Now i have a code in Sheet2 (for cell D4), which will unhide cells
based on values given in D87. The code is working fine.

My problem is the rows dont hide/unhide, till click on some other cell
and click back on D4 in Sheet2. Can this be fixed ?? My code is below

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

With Range("Offering_Info")
If Not Intersect(.Cells, Target) Is Nothing Then
Application.ScreenUpdating = False
Rows("5:14").Hidden = True
If IsNumeric(.Value) Then
Rows("5:5"). _
Resize(1 + CLng(.Value) * 2).Hidden = False
End If
Application.ScreenUpdating = True
End If
End With
End Sub

 
Reply With Quote
 
 
 
 
Bob Phillips
Guest
Posts: n/a
 
      16th Aug 2007
Works fine for me (I presume that Offering_Info is D4?). What Excel version?

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Ram" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi,
>
> I have a cell (D4) in Sheet 2, which is referenced to cell (D87) in
> Sheet1.
>
> Cell D4 has a dropdown (thru Data -> Validation -> list) Values are :-
> Select one, 1, 2, 3, 4, 5
>
> Now i have a code in Sheet2 (for cell D4), which will unhide cells
> based on values given in D87. The code is working fine.
>
> My problem is the rows dont hide/unhide, till click on some other cell
> and click back on D4 in Sheet2. Can this be fixed ?? My code is below
>
> Private Sub Worksheet_SelectionChange(ByVal Target As Range)
>
> With Range("Offering_Info")
> If Not Intersect(.Cells, Target) Is Nothing Then
> Application.ScreenUpdating = False
> Rows("5:14").Hidden = True
> If IsNumeric(.Value) Then
> Rows("5:5"). _
> Resize(1 + CLng(.Value) * 2).Hidden = False
> End If
> Application.ScreenUpdating = True
> End If
> End With
> End Sub
>



 
Reply With Quote
 
Ram
Guest
Posts: n/a
 
      16th Aug 2007
On Aug 16, 4:15 pm, "Bob Phillips" <bob....@somewhere.com> wrote:
> Works fine for me (I presume that Offering_Info is D4?). What Excel version?
>
> --
> ---
> HTH
>
> Bob
>
> (there's no email, no snail mail, but somewhere should be gmail in my addy)
>
> "Ram" <sreeram....@gmail.com> wrote in message
>
> news:(E-Mail Removed)...
>
>
>
> > Hi,

>
> > I have a cell (D4) in Sheet 2, which is referenced to cell (D87) in
> > Sheet1.

>
> > Cell D4 has a dropdown (thru Data -> Validation -> list) Values are :-
> > Select one, 1, 2, 3, 4, 5

>
> > Now i have a code in Sheet2 (for cell D4), which will unhide cells
> > based on values given in D87. The code is working fine.

>
> > My problem is the rows dont hide/unhide, till click on some other cell
> > and click back on D4 in Sheet2. Can this be fixed ?? My code is below

>
> > Private Sub Worksheet_SelectionChange(ByVal Target As Range)

>
> > With Range("Offering_Info")
> > If Not Intersect(.Cells, Target) Is Nothing Then
> > Application.ScreenUpdating = False
> > Rows("5:14").Hidden = True
> > If IsNumeric(.Value) Then
> > Rows("5:5"). _
> > Resize(1 + CLng(.Value) * 2).Hidden = False
> > End If
> > Application.ScreenUpdating = True
> > End If
> > End With
> > End Sub- Hide quoted text -

>
> - Show quoted text -


Yes Bob, Offering_Info is D4. My excel version is Excel
2003(11.8142.8132) SP2.

The code works fine for me too. However as i mentioned I have to click
on a different cell lets say (D5) and the click back on (D4). Is it
working the same way for you?

 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      16th Aug 2007
Maybe using _selectionchange is the wrong event to tie into.

How about trying worksheet_change



Ram wrote:
>
> Hi,
>
> I have a cell (D4) in Sheet 2, which is referenced to cell (D87) in
> Sheet1.
>
> Cell D4 has a dropdown (thru Data -> Validation -> list) Values are :-
> Select one, 1, 2, 3, 4, 5
>
> Now i have a code in Sheet2 (for cell D4), which will unhide cells
> based on values given in D87. The code is working fine.
>
> My problem is the rows dont hide/unhide, till click on some other cell
> and click back on D4 in Sheet2. Can this be fixed ?? My code is below
>
> Private Sub Worksheet_SelectionChange(ByVal Target As Range)
>
> With Range("Offering_Info")
> If Not Intersect(.Cells, Target) Is Nothing Then
> Application.ScreenUpdating = False
> Rows("5:14").Hidden = True
> If IsNumeric(.Value) Then
> Rows("5:5"). _
> Resize(1 + CLng(.Value) * 2).Hidden = False
> End If
> Application.ScreenUpdating = True
> End If
> End With
> End Sub


--

Dave Peterson
 
Reply With Quote
 
Bob Phillips
Guest
Posts: n/a
 
      16th Aug 2007
As Dave says, it sounds as though it is after changing the value that you
need to switch cells, so you should be using Selection_Change event.

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Ram" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> On Aug 16, 4:15 pm, "Bob Phillips" <bob....@somewhere.com> wrote:
>> Works fine for me (I presume that Offering_Info is D4?). What Excel
>> version?
>>
>> --
>> ---
>> HTH
>>
>> Bob
>>
>> (there's no email, no snail mail, but somewhere should be gmail in my
>> addy)
>>
>> "Ram" <sreeram....@gmail.com> wrote in message
>>
>> news:(E-Mail Removed)...
>>
>>
>>
>> > Hi,

>>
>> > I have a cell (D4) in Sheet 2, which is referenced to cell (D87) in
>> > Sheet1.

>>
>> > Cell D4 has a dropdown (thru Data -> Validation -> list) Values are :-
>> > Select one, 1, 2, 3, 4, 5

>>
>> > Now i have a code in Sheet2 (for cell D4), which will unhide cells
>> > based on values given in D87. The code is working fine.

>>
>> > My problem is the rows dont hide/unhide, till click on some other cell
>> > and click back on D4 in Sheet2. Can this be fixed ?? My code is below

>>
>> > Private Sub Worksheet_SelectionChange(ByVal Target As Range)

>>
>> > With Range("Offering_Info")
>> > If Not Intersect(.Cells, Target) Is Nothing Then
>> > Application.ScreenUpdating = False
>> > Rows("5:14").Hidden = True
>> > If IsNumeric(.Value) Then
>> > Rows("5:5"). _
>> > Resize(1 + CLng(.Value) * 2).Hidden = False
>> > End If
>> > Application.ScreenUpdating = True
>> > End If
>> > End With
>> > End Sub- Hide quoted text -

>>
>> - Show quoted text -

>
> Yes Bob, Offering_Info is D4. My excel version is Excel
> 2003(11.8142.8132) SP2.
>
> The code works fine for me too. However as i mentioned I have to click
> on a different cell lets say (D5) and the click back on (D4). Is it
> working the same way for you?
>



 
Reply With Quote
 
Bob Phillips
Guest
Posts: n/a
 
      16th Aug 2007
I mean Worksheet_Change.

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Bob Phillips" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> As Dave says, it sounds as though it is after changing the value that you
> need to switch cells, so you should be using Selection_Change event.
>
> --
> ---
> HTH
>
> Bob
>
> (there's no email, no snail mail, but somewhere should be gmail in my
> addy)
>
>
>
> "Ram" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> On Aug 16, 4:15 pm, "Bob Phillips" <bob....@somewhere.com> wrote:
>>> Works fine for me (I presume that Offering_Info is D4?). What Excel
>>> version?
>>>
>>> --
>>> ---
>>> HTH
>>>
>>> Bob
>>>
>>> (there's no email, no snail mail, but somewhere should be gmail in my
>>> addy)
>>>
>>> "Ram" <sreeram....@gmail.com> wrote in message
>>>
>>> news:(E-Mail Removed)...
>>>
>>>
>>>
>>> > Hi,
>>>
>>> > I have a cell (D4) in Sheet 2, which is referenced to cell (D87) in
>>> > Sheet1.
>>>
>>> > Cell D4 has a dropdown (thru Data -> Validation -> list) Values are :-
>>> > Select one, 1, 2, 3, 4, 5
>>>
>>> > Now i have a code in Sheet2 (for cell D4), which will unhide cells
>>> > based on values given in D87. The code is working fine.
>>>
>>> > My problem is the rows dont hide/unhide, till click on some other cell
>>> > and click back on D4 in Sheet2. Can this be fixed ?? My code is below
>>>
>>> > Private Sub Worksheet_SelectionChange(ByVal Target As Range)
>>>
>>> > With Range("Offering_Info")
>>> > If Not Intersect(.Cells, Target) Is Nothing Then
>>> > Application.ScreenUpdating = False
>>> > Rows("5:14").Hidden = True
>>> > If IsNumeric(.Value) Then
>>> > Rows("5:5"). _
>>> > Resize(1 + CLng(.Value) * 2).Hidden = False
>>> > End If
>>> > Application.ScreenUpdating = True
>>> > End If
>>> > End With
>>> > End Sub- Hide quoted text -
>>>
>>> - Show quoted text -

>>
>> Yes Bob, Offering_Info is D4. My excel version is Excel
>> 2003(11.8142.8132) SP2.
>>
>> The code works fine for me too. However as i mentioned I have to click
>> on a different cell lets say (D5) and the click back on (D4). Is it
>> working the same way for you?
>>

>
>



 
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
VBA Code Correction RichIT Microsoft Excel Programming 3 10th Aug 2006 05:02 PM
VBA Code Correction RichIT Microsoft Excel Programming 2 10th Aug 2006 04:30 PM
Code Correction Need =?Utf-8?B?U2FmaQ==?= Microsoft Excel Programming 0 30th Jul 2006 06:05 PM
Spell Check Correction Case Correction Code Question Dave Elliott Microsoft Access Forms 1 17th Sep 2004 04:40 PM
Correction to :Is there better code than this: 1aae Microsoft Access Form Coding 1 2nd Apr 2004 01:56 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:54 PM.