Closed Thread
Results 1 to 3 of 3

Visual Basic Help - Need N/A or Drop Down List to Populate - Based on Data in Another Cell

Hybrid View

lomo0208 Visual Basic Help - Need N/A... 09-14-2015, 10:44 AM
lomo0208 Re: Visual Basic Help - Need... 09-14-2015, 12:29 PM
Fotis1991 Re: Visual Basic Help - Need... 09-15-2015, 02:32 AM
  1. #1
    Registered User
    Join Date
    09-11-2015
    Location
    Dallas, TX
    MS-Off Ver
    2010
    Posts
    8

    Visual Basic Help - Need N/A or Drop Down List to Populate - Based on Data in Another Cell

    I posted this question on another group and was able to get an answer, however I need one item changed and I have not been able to get assistance on this change. I am hoping someone here can help me out with this question!

    Original question:
    Cell B8 can be blank, Yes or No.
    When B8 is Yes, I need my data validation list to appear in fields G28:G35. This is simple and I have my listed named Status.
    When B9 is No, I need N/A to automatically populate in fields G28:G35. I also need these cells locked.
    I found some VBA help topics but I cannot get it to work for me.

    I am not sure if I need to add my data validation first or second or what to key in Visual Basic. I will be repeating this same scenario at least 15 times with different cells.

    Original Response:

    Private Sub Worksheet_Change(ByVal Target As Range)
        If Target.Address = "$B$8" Then
            Select Case Target
                Case "Yes"
                    Range("G28:G35").Select
                    Range("G28:G35").Locked = False
                    With Selection.Validation
                        .Delete
                        .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
                            xlBetween, Formula1:="=IF($B$8=""Yes"",INDIRECT(""Status""))"
                        .IgnoreBlank = True
                        .InCellDropdown = True
                        .InputTitle = ""
                        .ErrorTitle = ""
                        .InputMessage = ""
                        .ErrorMessage = ""
                        .ShowInput = True
                        .ShowError = True
                     End With
                Case "No"
                    Range("G28:G35").Locked = True
                    For Each cell In Range("G28:G35")
                        cell.Value = "N/A"
                    Next cell
                Case Empty
                    Range("G28:G35").Locked = False
                    For Each cell In Range("G28:G35")
                        cell.ClearContents
                    Next cell
            End Select
        End If
    End Sub
    New Assistance Needed:
    I decided to move cell B8 to another sheet because I am going to have a large number of yes/no questions. The cell is now on a sheet called Account Summary. I tried to update the code and reference this sheet, but apparently I do not know what I am doing. I really need this to work. I have researched and tried so many different ways to reference the other tab and I just can't figure it out.

    If someone incorrectly enters "No" in B8 and deletes "No", the N/As in the range will disappear. If they change "No" to "Yes" in B8, the N/As remain in the range. Is it possible to update the code to indicate if "Yes" is selected, the cells will clear and only have the option of the drop down list? This is optional and I can live without this being done.

    Your help is greatly appreciated!
    Last edited by lomo0208; 09-14-2015 at 12:28 PM. Reason: Updating Coding

  2. #2
    Registered User
    Join Date
    09-11-2015
    Location
    Dallas, TX
    MS-Off Ver
    2010
    Posts
    8

    Re: Visual Basic Help - Need N/A or Drop Down List to Populate - Based on Data in Another

    Thank you for the quick response and feedback. The original post has been updated.

  3. #3
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Visual Basic Help - Need N/A or Drop Down List to Populate - Based on Data in Another

    Thread closed as per OP request, as will post in Comercial fORUM.
    Regards

    Fotis.

    -This is my Greek whisper to Europe.

    --Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.

    Advanced Excel Techniques: http://excelxor.com/

    --KISS(Keep it simple Stupid)

    --Bring them back.

    ---See about Acropolis of Athens.

    --Visit Greece.

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 3
    Last Post: 01-28-2015, 01:09 AM
  2. LIST and Data Validation, Visual Basic in Excel 2010
    By softik in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 09-30-2014, 03:28 AM
  3. Populate cell data based on data validation (drop down list)
    By ish_baho in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 02-05-2014, 11:47 PM
  4. Need HELP Locking cells based on another cell in Visual Basic!!
    By Lynsey in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-28-2013, 01:32 PM
  5. Replies: 7
    Last Post: 09-11-2013, 07:35 PM
  6. Populate data in cell based on drop down list selection
    By dwoodson297 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-14-2013, 02:07 PM
  7. Populate a cell based on input from a drop down list
    By TroyDurham in forum Excel General
    Replies: 9
    Last Post: 01-19-2009, 09:47 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1