Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2011-03-07
6
Medium Priority
?
347 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 2000 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a serious pitfall that can happen when deleting shapes using VBA.
Windows Explorer lets you open cabinet (cab) files like any other folder. In VBA you can easily handle normal files and folders, but opening and indeed creating cabinet files takes a lot more - and that's you'll find here.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

971 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