#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 46
Default Listbox

Hi All

I have two lists... depending upon the selction of one list I want to
update another list...
e.g. Country List - Here I am listing UK, Ireland
My second List contains Cities, i.e. London, Manchester, Leeds, Dublin etc...

Now if I select UK in Country list I want to display only UK cities in City
list (i.e. London, Machester, Leeds etc) and If I select Ireland then only
Ireland cities (i.e. Dublin etc)

I have implemeted this functionality creating Named ranges... have created
3 lists, gave them name, and used if condition... everything is working
fine... but issue is earlier selection...

If I Select UK... obviously my city list is currently displaying only UK
cities... here if I am selecting lets say London... now when I select Ireland
in country list... my city list is getting updated with Ireland cities but my
previous selection i.e London is still there... I don't want to display
london when I select Irelant... i want to set it either to any default
value... or blank... but certainly not London...

do I need to write a code to do this?? if yes how? bec's macro is not
identifying list?? and what would be the trigger function??

Please help... lokking forward for your prompt reply... thanks

Milind


  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,722
Default Listbox

Correct, you will need a VB event macro. Right click on sheet tab, view code.
Paste this in, modifying as needed. Note that this will make the second cell
blank.

Private Sub Worksheet_Change(ByVal Target As Range)

'Change to cell with first list
If Intersect(Target, Range("A2")) Is Nothing Then Exit Sub

'Change to cell with second list
Range("A3").ClearContents
End Sub
--
Best Regards,

Luke M
*Remember to click "yes" if this post helped you!*


"Milind Keer" wrote:

Hi All

I have two lists... depending upon the selction of one list I want to
update another list...
e.g. Country List - Here I am listing UK, Ireland
My second List contains Cities, i.e. London, Manchester, Leeds, Dublin etc...

Now if I select UK in Country list I want to display only UK cities in City
list (i.e. London, Machester, Leeds etc) and If I select Ireland then only
Ireland cities (i.e. Dublin etc)

I have implemeted this functionality creating Named ranges... have created
3 lists, gave them name, and used if condition... everything is working
fine... but issue is earlier selection...

If I Select UK... obviously my city list is currently displaying only UK
cities... here if I am selecting lets say London... now when I select Ireland
in country list... my city list is getting updated with Ireland cities but my
previous selection i.e London is still there... I don't want to display
london when I select Irelant... i want to set it either to any default
value... or blank... but certainly not London...

do I need to write a code to do this?? if yes how? bec's macro is not
identifying list?? and what would be the trigger function??

Please help... lokking forward for your prompt reply... thanks

Milind


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 46
Default Listbox

Hi Luke

Thanks for the prompt reply... I thought about this option but on any change
this function is getting called and and resetiing the values... which I don't
want....

Basically what I want is... If I select UK... then other other list box
should retain the value if it belongs to UK... but if I select Ireland then
if UK city is already there in second list box it should updated to blank....
i know this is something possible thr' coding but don;t know which event
should I use....

Is there any event for Dropdown list...??

-milind





"Luke M" wrote:

Correct, you will need a VB event macro. Right click on sheet tab, view code.
Paste this in, modifying as needed. Note that this will make the second cell
blank.

Private Sub Worksheet_Change(ByVal Target As Range)

'Change to cell with first list
If Intersect(Target, Range("A2")) Is Nothing Then Exit Sub

'Change to cell with second list
Range("A3").ClearContents
End Sub
--
Best Regards,

Luke M
*Remember to click "yes" if this post helped you!*


"Milind Keer" wrote:

Hi All

I have two lists... depending upon the selction of one list I want to
update another list...
e.g. Country List - Here I am listing UK, Ireland
My second List contains Cities, i.e. London, Manchester, Leeds, Dublin etc...

Now if I select UK in Country list I want to display only UK cities in City
list (i.e. London, Machester, Leeds etc) and If I select Ireland then only
Ireland cities (i.e. Dublin etc)

I have implemeted this functionality creating Named ranges... have created
3 lists, gave them name, and used if condition... everything is working
fine... but issue is earlier selection...

If I Select UK... obviously my city list is currently displaying only UK
cities... here if I am selecting lets say London... now when I select Ireland
in country list... my city list is getting updated with Ireland cities but my
previous selection i.e London is still there... I don't want to display
london when I select Irelant... i want to set it either to any default
value... or blank... but certainly not London...

do I need to write a code to do this?? if yes how? bec's macro is not
identifying list?? and what would be the trigger function??

Please help... lokking forward for your prompt reply... thanks

Milind


  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 46
Default Listbox

Hey Luke...

I resolved this issue...

Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Row = 3 And Target.Column = 3 Then
If Range("C3").Value = "IRE" Then
Range("C4").Value = "Dublin"
End If

If Range("C3").Value = "UK" And Range("C4").Value = "Dublin" Then
Range("C4").Value = "London"
End If
Else
Exit Sub
End If

End Sub


I will make more robust... but its working.... thanks a ton...





"Milind Keer" wrote:

Hi Luke

Thanks for the prompt reply... I thought about this option but on any change
this function is getting called and and resetiing the values... which I don't
want....

Basically what I want is... If I select UK... then other other list box
should retain the value if it belongs to UK... but if I select Ireland then
if UK city is already there in second list box it should updated to blank....
i know this is something possible thr' coding but don;t know which event
should I use....

Is there any event for Dropdown list...??

-milind





"Luke M" wrote:

Correct, you will need a VB event macro. Right click on sheet tab, view code.
Paste this in, modifying as needed. Note that this will make the second cell
blank.

Private Sub Worksheet_Change(ByVal Target As Range)

'Change to cell with first list
If Intersect(Target, Range("A2")) Is Nothing Then Exit Sub

'Change to cell with second list
Range("A3").ClearContents
End Sub
--
Best Regards,

Luke M
*Remember to click "yes" if this post helped you!*


"Milind Keer" wrote:

Hi All

I have two lists... depending upon the selction of one list I want to
update another list...
e.g. Country List - Here I am listing UK, Ireland
My second List contains Cities, i.e. London, Manchester, Leeds, Dublin etc...

Now if I select UK in Country list I want to display only UK cities in City
list (i.e. London, Machester, Leeds etc) and If I select Ireland then only
Ireland cities (i.e. Dublin etc)

I have implemeted this functionality creating Named ranges... have created
3 lists, gave them name, and used if condition... everything is working
fine... but issue is earlier selection...

If I Select UK... obviously my city list is currently displaying only UK
cities... here if I am selecting lets say London... now when I select Ireland
in country list... my city list is getting updated with Ireland cities but my
previous selection i.e London is still there... I don't want to display
london when I select Irelant... i want to set it either to any default
value... or blank... but certainly not London...

do I need to write a code to do this?? if yes how? bec's macro is not
identifying list?? and what would be the trigger function??

Please help... lokking forward for your prompt reply... thanks

Milind


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Listbox 2 takes the value of Listbox 1 Illya Teideman Excel Discussion (Misc queries) 3 April 10th 07 03:20 PM
listbox Oggy Excel Discussion (Misc queries) 3 January 6th 07 09:45 PM
listbox B conditional of input in Listbox A Kim K Excel Discussion (Misc queries) 1 October 31st 06 08:27 PM
Listbox B if LIstbox A equals Kim K Excel Discussion (Misc queries) 2 October 31st 06 07:03 PM
Need help with Listbox Lizzie_S Excel Discussion (Misc queries) 3 July 22nd 05 03:42 AM


All times are GMT +1. The time now is 09:39 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"