Solved

Macro to populate cells or allow for validation input

Posted on 2016-08-01
10
41 Views
Last Modified: 2016-08-01
EE Pros,

I have a Worksheet that has a 3 dropdown cells.  In the first cell, if you select "Consistently", then the other two cells identified, are auto. populated.  If "Consistently" is not selected, you can put any other choice from the list box in the cells.

That's it!  Much thanks in advance.

B.
Macro-for-populating-Cells.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
  • 5
  • 5
10 Comments
 
LVL 31

Expert Comment

by:Subodh Tiwari (Neeraj)
ID: 41737397
Your request is not clear, at least to me.
Would you please elaborate it to let us know your exact requirement?
0
 

Author Comment

by:Bright01
ID: 41737414
Neeraj,  my apologies.

I have three cells where there are list box drop downs.  In the first cell (E8) you can select 6 different choices.  What I want a Macro to do is that if the first choice in the selection for E8, "Consistently", is selected, I want it to automatically place the choices for the other two boxes.  For F8, it would place "Achieve" in the box and for F10, "n/a".  IF "Consistently" is not selected for E8, then any dropdown selection can be choosen for all three boxes.

Does that make sense?

B.
0
 
LVL 31

Accepted Solution

by:
Subodh Tiwari (Neeraj) earned 500 total points
ID: 41737437
Place the following code on Sheet1 Module. To do that, right click the Sheet1 Tab --> View Code and place the following code into the opened code window.

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.CountLarge > 1 Then Exit Sub
If Target.Address(0, 0) = "E8" Then
    Application.EnableEvents = False
    Range("F8").Value = "ACHIEVE"
    Range("H8").Value = "n/a"
    Application.EnableEvents = True
End If
End Sub

Open in new window

Does this help?
0
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 

Author Closing Comment

by:Bright01
ID: 41737466
Neeraj,

You nailed it!  Thank you very much. Great job.  Works perfectly.

B.
0
 

Author Comment

by:Bright01
ID: 41737551
Neeraj,

Quick question.  Let's say I need the same capability down the E column, say E8:E26, how would I set up the macro to adapt to choices in other E selections between that range?  In other words, if I went to E25 and selected "Consistently" in E25, how would I get it to properly populate the other F & H25 cells?

B.
0
 
LVL 31

Expert Comment

by:Subodh Tiwari (Neeraj)
ID: 41737569
You're welcome. Glad to help.

In that case replace the existing code with the following one...

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.CountLarge > 1 Then Exit Sub
If Not Intersect(Target, Range("E8:E26")) Is Nothing Then
    Application.EnableEvents = False
    Target.Offset(0, 1).Value = "ACHIEVE"
    Target.Offset(0, 3).Value = "n/a"
    Application.EnableEvents = True
End If
End Sub

Open in new window

0
 

Author Comment

by:Bright01
ID: 41737597
This works, but one small problem.  In the original ask, I had said, "if the first choice in the selection for E8, "Consistently", is selected...."  The way the macro is presently written, if any selection is made in E8:E26, it populates F8:26 with "Achieve".  It's only suppose to do that when "Consistently" is choosen in the E Cells.

B.
0
 
LVL 31

Expert Comment

by:Subodh Tiwari (Neeraj)
ID: 41737613
Ah.. okay got it.
Please try the below code.....
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.CountLarge > 1 Then Exit Sub
If Not Intersect(Target, Range("E8:E26")) Is Nothing Then
    If Target = "CONSISTENTLY" Then
        Application.EnableEvents = False
        Target.Offset(0, 1).Value = "ACHIEVE"
        Target.Offset(0, 3).Value = "n/a"
        Application.EnableEvents = True
    End If
End If
End Sub

Open in new window

0
 

Author Comment

by:Bright01
ID: 41737673
Thank you!  Now it works perfectly.

B.
0
 
LVL 31

Expert Comment

by:Subodh Tiwari (Neeraj)
ID: 41737676
You're welcome. :)
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone 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

This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

732 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