Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 69
Default dependant lists- trigger a blank when 1st one is changed?

Hello:
I currently have two columns:
Column A is Countries
Column B is Cities associated with those countries in Column A

I have the data validation set up so that when you select Australia, for
example, in Column A, it limits/narrows the drop down list in Column B to
only show choices of cities in Australia (Sydney, Brisbane, etc.).

Here's my problem: when I have already selected the Country and city
(Australia and Sydney for example) and then later decide to change the
Country choice, it still shows the old city that I chose for Australia. So, I
may change the country to Japan, but it will still show Sydney in Column B
unless I click on the Column B drop down.

In order to avoid careless mistakes, I would like to have it automatically
trigger the Column B to go blank if Column A is changed. Thus prompting the
person to know that they have to fill a choice in for city from the Column B
drop down.
Is this possible?

Much thanks!!
JR
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 15,768
Default dependant lists- trigger a blank when 1st one is changed?

You can do this with an event macro.

Assume the primary drop down list is in cell A2 and the dependent list is in
B2.

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
On Error GoTo sub_exit
If Target.Address = "$A$2" Then
Range("B2").ClearContents
End If
sub_exit:
Application.EnableEvents = True
End Sub

To use this:
Select the sheet where you want this to happen
Right click the sheet tab and select View code
Copy/paste the code above into the window that opens
Close the window to return to Excel

--
Biff
Microsoft Excel MVP


"Roady" wrote in message
...
Hello:
I currently have two columns:
Column A is Countries
Column B is Cities associated with those countries in Column A

I have the data validation set up so that when you select Australia, for
example, in Column A, it limits/narrows the drop down list in Column B to
only show choices of cities in Australia (Sydney, Brisbane, etc.).

Here's my problem: when I have already selected the Country and city
(Australia and Sydney for example) and then later decide to change the
Country choice, it still shows the old city that I chose for Australia.
So, I
may change the country to Japan, but it will still show Sydney in Column B
unless I click on the Column B drop down.

In order to avoid careless mistakes, I would like to have it automatically
trigger the Column B to go blank if Column A is changed. Thus prompting
the
person to know that they have to fill a choice in for city from the Column
B
drop down.
Is this possible?

Much thanks!!
JR



  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default dependant lists- trigger a blank when 1st one is changed?

JR

Copy/paste this to the sheet module by right-click on sheet tab and "View Code"
to open the module.

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count 1 Then Exit Sub
If Intersect(Target, Me.Range("A1::A100")) Is Nothing Then Exit Sub
On Error GoTo CleanUp
Application.EnableEvents = False
With Target
If .Value < "" Then
.Offset(0, 1) = ""
End If
End With
CleanUp:
Application.EnableEvents = True
End Sub

When user re-selects from Country dropdown, Cities dropdown will go blank in
same row.


Gord

On Mon, 28 Jan 2008 12:35:01 -0800, Roady
wrote:

Hello:
I currently have two columns:
Column A is Countries
Column B is Cities associated with those countries in Column A

I have the data validation set up so that when you select Australia, for
example, in Column A, it limits/narrows the drop down list in Column B to
only show choices of cities in Australia (Sydney, Brisbane, etc.).

Here's my problem: when I have already selected the Country and city
(Australia and Sydney for example) and then later decide to change the
Country choice, it still shows the old city that I chose for Australia. So, I
may change the country to Japan, but it will still show Sydney in Column B
unless I click on the Column B drop down.

In order to avoid careless mistakes, I would like to have it automatically
trigger the Column B to go blank if Column A is changed. Thus prompting the
person to know that they have to fill a choice in for city from the Column B
drop down.
Is this possible?

Much thanks!!
JR


  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 69
Default dependant lists- trigger a blank when 1st one is changed?

Hi T-

So it worked like magic for the first row but then wasn't working for all
subsequent rows. I copied and pasted exactly what you had written except
switching out A & B for O and U, respectively (since those are the actual
columns).

any thoughts on troubleshooting?
Thanks,
Jen

"T. Valko" wrote:

You can do this with an event macro.

Assume the primary drop down list is in cell A2 and the dependent list is in
B2.

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
On Error GoTo sub_exit
If Target.Address = "$A$2" Then
Range("B2").ClearContents
End If
sub_exit:
Application.EnableEvents = True
End Sub

To use this:
Select the sheet where you want this to happen
Right click the sheet tab and select View code
Copy/paste the code above into the window that opens
Close the window to return to Excel

--
Biff
Microsoft Excel MVP


"Roady" wrote in message
...
Hello:
I currently have two columns:
Column A is Countries
Column B is Cities associated with those countries in Column A

I have the data validation set up so that when you select Australia, for
example, in Column A, it limits/narrows the drop down list in Column B to
only show choices of cities in Australia (Sydney, Brisbane, etc.).

Here's my problem: when I have already selected the Country and city
(Australia and Sydney for example) and then later decide to change the
Country choice, it still shows the old city that I chose for Australia.
So, I
may change the country to Japan, but it will still show Sydney in Column B
unless I click on the Column B drop down.

In order to avoid careless mistakes, I would like to have it automatically
trigger the Column B to go blank if Column A is changed. Thus prompting
the
person to know that they have to fill a choice in for city from the Column
B
drop down.
Is this possible?

Much thanks!!
JR




  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 15,768
Default dependant lists- trigger a blank when 1st one is changed?

See Gord's example. He wrote it to work for a range of cells where I wrote
mine to work on only a single cell.

--
Biff
Microsoft Excel MVP


"Roady" wrote in message
...
Hi T-

So it worked like magic for the first row but then wasn't working for all
subsequent rows. I copied and pasted exactly what you had written except
switching out A & B for O and U, respectively (since those are the actual
columns).

any thoughts on troubleshooting?
Thanks,
Jen

"T. Valko" wrote:

You can do this with an event macro.

Assume the primary drop down list is in cell A2 and the dependent list is
in
B2.

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
On Error GoTo sub_exit
If Target.Address = "$A$2" Then
Range("B2").ClearContents
End If
sub_exit:
Application.EnableEvents = True
End Sub

To use this:
Select the sheet where you want this to happen
Right click the sheet tab and select View code
Copy/paste the code above into the window that opens
Close the window to return to Excel

--
Biff
Microsoft Excel MVP


"Roady" wrote in message
...
Hello:
I currently have two columns:
Column A is Countries
Column B is Cities associated with those countries in Column A

I have the data validation set up so that when you select Australia,
for
example, in Column A, it limits/narrows the drop down list in Column B
to
only show choices of cities in Australia (Sydney, Brisbane, etc.).

Here's my problem: when I have already selected the Country and city
(Australia and Sydney for example) and then later decide to change the
Country choice, it still shows the old city that I chose for Australia.
So, I
may change the country to Japan, but it will still show Sydney in
Column B
unless I click on the Column B drop down.

In order to avoid careless mistakes, I would like to have it
automatically
trigger the Column B to go blank if Column A is changed. Thus prompting
the
person to know that they have to fill a choice in for city from the
Column
B
drop down.
Is this possible?

Much thanks!!
JR








  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 15,768
Default dependant lists- trigger a blank when 1st one is changed?

Here's Gord's code modified to work on column O and column U:

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count 1 Then Exit Sub
If Intersect(Target, Me.Range("O1:O100")) Is Nothing Then Exit Sub
On Error GoTo CleanUp
Application.EnableEvents = False
With Target
If .Value < "" Then
.Offset(0, 6) = ""
End If
End With
CleanUp:
Application.EnableEvents = True
End Sub

Adjust the range as needed in this line:

If Intersect(Target, Me.Range("O1:O100"))........

Column U is defined in this line:

..Offset(0, 6)



--
Biff
Microsoft Excel MVP


"T. Valko" wrote in message
...
See Gord's example. He wrote it to work for a range of cells where I wrote
mine to work on only a single cell.

--
Biff
Microsoft Excel MVP


"Roady" wrote in message
...
Hi T-

So it worked like magic for the first row but then wasn't working for all
subsequent rows. I copied and pasted exactly what you had written except
switching out A & B for O and U, respectively (since those are the actual
columns).

any thoughts on troubleshooting?
Thanks,
Jen

"T. Valko" wrote:

You can do this with an event macro.

Assume the primary drop down list is in cell A2 and the dependent list
is in
B2.

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
On Error GoTo sub_exit
If Target.Address = "$A$2" Then
Range("B2").ClearContents
End If
sub_exit:
Application.EnableEvents = True
End Sub

To use this:
Select the sheet where you want this to happen
Right click the sheet tab and select View code
Copy/paste the code above into the window that opens
Close the window to return to Excel

--
Biff
Microsoft Excel MVP


"Roady" wrote in message
...
Hello:
I currently have two columns:
Column A is Countries
Column B is Cities associated with those countries in Column A

I have the data validation set up so that when you select Australia,
for
example, in Column A, it limits/narrows the drop down list in Column B
to
only show choices of cities in Australia (Sydney, Brisbane, etc.).

Here's my problem: when I have already selected the Country and city
(Australia and Sydney for example) and then later decide to change the
Country choice, it still shows the old city that I chose for
Australia.
So, I
may change the country to Japan, but it will still show Sydney in
Column B
unless I click on the Column B drop down.

In order to avoid careless mistakes, I would like to have it
automatically
trigger the Column B to go blank if Column A is changed. Thus
prompting
the
person to know that they have to fill a choice in for city from the
Column
B
drop down.
Is this possible?

Much thanks!!
JR







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
Dependant lists help needed Dando265 Excel Discussion (Misc queries) 16 June 12th 07 09:10 AM
Dependant Lists Question ALEX Excel Worksheet Functions 5 February 6th 07 03:23 PM
3 way dependant lists stratmyster Excel Worksheet Functions 3 July 24th 06 05:21 PM
Dependant Lists in Excel Browett Excel Worksheet Functions 2 July 14th 06 04:49 AM
Dependant Lists Steve Bladon Excel Discussion (Misc queries) 2 June 13th 05 12:28 PM


All times are GMT +1. The time now is 08:28 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"