Solved

How do delete or insert values in another cell based on validation selction in adjacent cell

Posted on 2011-03-07
6
286 Views
Last Modified: 2012-05-11
Okay here is where I am at:

My friend and I are trying to creat a NCAA basket ball bracket in excel.  I am using validation dropdown lists to popolate the cells and then a second worksheet to create a new validation list for the next round based on what was selected previously.   This works great but I want to add the additional functionality that if they select someone in round of 32 then select the same team in the sweet 16 to win but decided that the team would actually lose in the previous round that any rounds after that would clear the name since it was selected to lose prior to that.   I am not sure if there is a way through VBA or someother method to make this happen.

I have attached my spreadsheet for reference.  

Thanks!
Test-Sheet-3.xlsm
0
Comment
Question by:Apex623
  • 3
  • 2
6 Comments
 
LVL 39

Accepted Solution

by:
nutsch earned 500 total points
ID: 35060913
Hi Apex,

You can use the attached code. BUT you will have to update your two championship games column so they start cleanly in row 6 and not row 7. From the way you designed your file, you shouldn't have any issues doing that.

Thomas

Private Sub Worksheet_Change(ByVal Target As Range)
Dim cl As Range, i As Long, strTeam As String

If Not Intersect(Target, Range("D6:N38")) Is Nothing Then
    Application.EnableEvents = False
        For i = Target.Column + 1 To 9
            strTeam = Target.Offset(, i - Target.Column).MergeArea.Cells(1, 1)
            
            For Each cl In Target.Offset(, i - Target.Column).MergeArea.Cells
                If cl.Offset(, -1) = strTeam Then GoTo noIssueLeft
            Next
            
            Target.Offset(, i - Target.Column).MergeArea.ClearContents

noIssueLeft:
        Next i
        
        For i = Target.Column + 1 To 9 Step -1
            strTeam = Target.Offset(, i - Target.Column).MergeArea.Cells(1, 1)
            
            For Each cl In Target.Offset(, i - Target.Column).MergeArea.Cells
                If cl.Offset(, 1) = strTeam Then GoTo noIssueLeft
            Next
        
            Target.Offset(, i - Target.Column).MergeArea.ClearContents
noIssueRight:
        Next i
        
    Application.EnableEvents = True
End If

End Sub

Open in new window

0
 
LVL 5

Expert Comment

by:wellous
ID: 35060964
Hi,
<Quoted>
>>if they select someone in round of 32 then select the same team in the sweet 16 to win but decided that the team would actually lose in the previous round that any rounds after that would clear the name since it was selected to lose prior to that. <<
</Unquoted>
Yes , you are totally correct , what do you want the VBA to do for you ?
you stated in yr Validation lists that each cell from [Round of 32] is taking the Value from [Field of 64] and [Sweet 16] is taking from [Field of 64] so on .... then you will never find a previously lost team in the next Fields or round ever :) very logic!

Again , what VBA should do here ?

Thanks
Wellous

0
 
LVL 1

Author Comment

by:Apex623
ID: 35061181
nutsch:

I will work with what you gave me today and back with you on the results.  It may be tonight before I can run it but I am excited to give it a try and I will make the suggested change to the champion.  

Wellous:
I want the list to narrow each time to make sure they only select from teams that are available.  However the could select say Arizona in round of 32, and then again in sweet 16 but if they go back and change round of 32 to Utah I want it to delete Arizona from round of 16 since it is no longer a choice.  Does that make since?

Thanks again for the responses I will get going on this.  After all the tournament is right around the corner!
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 1

Author Comment

by:Apex623
ID: 35061318
Nutsch:  Actually I could not wait and put the code in my worksheet and it works perfect.  
0
 
LVL 1

Author Closing Comment

by:Apex623
ID: 35061330
Great job thanks for your help.  I am sure I will have more questions as I work on this.
0
 
LVL 39

Expert Comment

by:nutsch
ID: 35061723
Glad to help, thanks for the grade.

Thomas
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Introduction This Article is a follow-up to my Mappit! Addin Article (http://www.experts-exchange.com/A_2613.html), it was inspired by an email posting I made to EUSPRIG (http://www.eusprig.org/index.htm), I will briefly cover: 1) An overvie…
Introduction While answering a recent question (http:/Q_27311462.html), I created an alternative function to the Excel Concatenate() function that you might find useful.  I tested several solutions and share the results in this article as well as t…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now