Solved

Conditional Cell Input Capability

Posted on 2011-03-12
6
266 Views
Last Modified: 2012-05-11

EE Professionals!

I'm running Excel 2010 and think I need a small macro to enforce several rules in a spreadsheet.  I have a spreadsheet that consists of two columns and 180 rows broken down into 12 sections of 15 associated rows per section.  I have attached a sample of the spreadsheet with 15 rows to keep it simple and than plan to apply the Macro for each section.  I need to have a macro that allows for input in the first column (A) and based on that answer, either restrict or allow additiional input both in the adjoining column (B) or in the rows below.  Here are the rules I'm trying to enforce:

If data in column A = "True", than you cannot input any data into adjointing cell B

If there is no data in column A or data = "N/A", than no data can exist in the adjointing cell B

If data in column A = "Partial" or "False", than data in cell B can be inputed from the dropdown list

When 3 false answers are created in a sequence (i.e. FALSE, FALSE, FALSE) in column A, than no more input is allowed in any of the cells below the third "FALSE" in sequence, within the cell range (i.e. A19:B33).

That's it!  "Thank you in advance".

B.
 Conditional-Cell-Selection-Sampl.xlsm
0
Comment
Question by:Bright01
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 30

Accepted Solution

by:
SiddharthRout earned 500 total points
ID: 35116147
You mentioned Range A19:B33 in the workbook so I am giving you and example pertaining to that range. Please amend it for realistic situation.

Sample Attached.

Sid

Code Used

Private Sub Worksheet_Change(ByVal Target As Range)
    Application.EnableEvents = False
    '~~> Check if the chnage is happening in range A19:A33
    If Not Intersect(Target, Range("A19:A33")) Is Nothing Then
        On Error Resume Next
        '~~> To check for 3 false conditions
        For i = 33 To 22 Step -1
            If Range("A" & i).Offset(-1).Value = "False" And _
            Range("A" & i).Offset(-2).Value = "False" And _
            Range("A" & i).Offset(-3).Value = "False" Then
                Target.Value = ""
                Application.EnableEvents = True
                Exit Sub
            End If
        Next
        On Error GoTo 0
    '~~> Check if the chnage is happening in B19:B33
    ElseIf Not Intersect(Target, Range("B19:B33")) Is Nothing Then
        '~~> To check for rest 3 conditions
        If Target.Offset(, -1).Value = "True" Or _
        Target.Offset(, -1).Value = "N/A" Or _
        Len(Trim(Target.Offset(, -1).Value)) = 0 Then Target.Value = ""
    End If
    Application.EnableEvents = True
End Sub

Open in new window

Conditional-Cell-Selection-Sampl.xlsm
0
 

Author Closing Comment

by:Bright01
ID: 35118137
OUTSTANDING JOB!!!

Works well;  I'll let you know how it goes as I incorporate it into my production copy.

Thanks much,

B.
0
 

Author Comment

by:Bright01
ID: 35118266
Sid,

How do I scale this?  I have 12 Sections with 15 selections in each Section.  It works perfectly for the first 15.  Can you give me some insight on scaling?

Thank you,

B.
0
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 
LVL 30

Expert Comment

by:SiddharthRout
ID: 35119162
Sure B :)

Can I see your actual file so that I can get my references correctly?

Sid
0
 

Author Comment

by:Bright01
ID: 35121356
Sid,

Here is the complete file.  You will see that there are 15 answers, 12 categories, a total of 180 responses. I think there are only two things that need to be modified for this to work.  One is that the condition on 3 False Answers has to be reset after the 15th answer (for the next category) and the other thing is that right now it needs to allow for three FALSE answers (I can only log two at the present time).

Thank you in advance.

B.
Total-File.xlsm
0
 

Author Comment

by:Bright01
ID: 35121674
Sid,

I'm going to ask this as a related question.  It's not fair for me to increase the scope of this when you did such a good job getting it right.

B.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.

740 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