Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2
Default How To Clear Previous Selection From a Drop Down

Good Afternoon-

I've created a simple spreadsheet in Excel 2007 which allows the user to
select from several work locations via a drop down. Based on the work
location selection, there are various work schedules they can select from.
This was done using the Indirect function within the data valadation section.

My question is how to clear a work schedule that was previously selected
once a new work location is selected. I'll try to give an example:

Work Locations
California
Florida
Texas


If California is selected they can choose 10 hour Shift or 12 Hour Shift

If the employee then goes back and changes the work location to Florida, the
drop down list changes to 8 Hour Shift, but the result displayed on the
screen still shows whatever was previously selected from the California work
location and won't change until the employee selects from the drop down.

I added a "-" as a work schedule within each of the tables and would like
that to be the default selection each time the work location is changed.

Any help is greatly appreciated.

Thanks-

Griff

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 51
Default How To Clear Previous Selection From a Drop Down

Try the following worksheet change event, remember to change A1 & B1 to suit
your worksheet.

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Application.Intersect(Target, _
Range("A1")) Is Nothing Then '<<<<<Work Locations
Application.EnableEvents = False
Range("B1").Select '<<<<<hour Shift
Selection.ClearContents
End If
Application.EnableEvents = True
End Sub

"The Griffster" wrote:

Good Afternoon-

I've created a simple spreadsheet in Excel 2007 which allows the user to
select from several work locations via a drop down. Based on the work
location selection, there are various work schedules they can select from.
This was done using the Indirect function within the data valadation section.

My question is how to clear a work schedule that was previously selected
once a new work location is selected. I'll try to give an example:

Work Locations
California
Florida
Texas


If California is selected they can choose 10 hour Shift or 12 Hour Shift

If the employee then goes back and changes the work location to Florida, the
drop down list changes to 8 Hour Shift, but the result displayed on the
screen still shows whatever was previously selected from the California work
location and won't change until the employee selects from the drop down.

I added a "-" as a work schedule within each of the tables and would like
that to be the default selection each time the work location is changed.

Any help is greatly appreciated.

Thanks-

Griff

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2
Default How To Clear Previous Selection From a Drop Down

PERFECT - thank you so much for the quick response!


"Stephen C" wrote:

Try the following worksheet change event, remember to change A1 & B1 to suit
your worksheet.

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Application.Intersect(Target, _
Range("A1")) Is Nothing Then '<<<<<Work Locations
Application.EnableEvents = False
Range("B1").Select '<<<<<hour Shift
Selection.ClearContents
End If
Application.EnableEvents = True
End Sub

"The Griffster" wrote:

Good Afternoon-

I've created a simple spreadsheet in Excel 2007 which allows the user to
select from several work locations via a drop down. Based on the work
location selection, there are various work schedules they can select from.
This was done using the Indirect function within the data valadation section.

My question is how to clear a work schedule that was previously selected
once a new work location is selected. I'll try to give an example:

Work Locations
California
Florida
Texas


If California is selected they can choose 10 hour Shift or 12 Hour Shift

If the employee then goes back and changes the work location to Florida, the
drop down list changes to 8 Hour Shift, but the result displayed on the
screen still shows whatever was previously selected from the California work
location and won't change until the employee selects from the drop down.

I added a "-" as a work schedule within each of the tables and would like
that to be the default selection each time the work location is changed.

Any help is greatly appreciated.

Thanks-

Griff

  #4   Report Post  
Junior Member
 
Posts: 2
Default

Quote:
Originally Posted by Stephen C View Post
Try the following worksheet change event, remember to change A1 & B1 to suit
your worksheet.

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Application.Intersect(Target, _
Range("A1")) Is Nothing Then '<<<<<Work Locations
Application.EnableEvents = False
Range("B1").Select '<<<<<hour Shift
Selection.ClearContents
End If
Application.EnableEvents = True
End Sub

"The Griffster" wrote:

Good Afternoon-

I've created a simple spreadsheet in Excel 2007 which allows the user to
select from several work locations via a drop down. Based on the work
location selection, there are various work schedules they can select from.
This was done using the Indirect function within the data valadation section.

My question is how to clear a work schedule that was previously selected
once a new work location is selected. I'll try to give an example:

Work Locations
California
Florida
Texas


If California is selected they can choose 10 hour Shift or 12 Hour Shift

If the employee then goes back and changes the work location to Florida, the
drop down list changes to 8 Hour Shift, but the result displayed on the
screen still shows whatever was previously selected from the California work
location and won't change until the employee selects from the drop down.

I added a "-" as a work schedule within each of the tables and would like
that to be the default selection each time the work location is changed.

Any help is greatly appreciated.

Thanks-

Griff
Your solution also answers my exact same question and works like a charm. I am a novice with VB so for the sake of others like me, let me explain what I did to make this work.

I have cell A as the main drop down list and cell B as the indirect list. I simply copied and pasted your VB code into the Visual Basic sheet of my Excel 2007 worksheet by selecting the DEVELOPER tab and then VISUAL BASIC tab in Excel 2007. I changed the first "A1" reference in your code to my cell A and your cell "A2" reference to my cell B then Saved the sheet. Like I said, it works like a charm. Hopefully my notes will help some other VB novice like me.

Thank you so much!
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
drop down list dependant of previous selection The Fru Fru Excel Worksheet Functions 1 December 3rd 08 03:33 AM
How do I clear a print area when the selection is grayed out? Ron Excel Discussion (Misc queries) 0 July 24th 07 11:28 PM
Validation - clear blanks from drop down Hayley Excel Worksheet Functions 13 July 1st 07 10:19 PM
Create new drop down from previous drop down selection Supe Excel Discussion (Misc queries) 3 January 19th 07 10:26 PM
drop down selection determines other drop down content lskelton Excel Discussion (Misc queries) 1 November 1st 05 11:14 PM


All times are GMT +1. The time now is 08:52 AM.

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

About Us

"It's about Microsoft Excel"