+ Reply to Thread
Results 1 to 2 of 2

VBA to Automatically add to range for drop down menu and prevent duplicates

  1. #1
    Registered User
    Join Date
    04-11-2017
    Location
    USA
    MS-Off Ver
    Office 365
    Posts
    2

    VBA to Automatically add to range for drop down menu and prevent duplicates

    Hello,

    I have the following code which for some reason is not working and I can't figure it out. If the value = True, then the code runs fine but if the value = False, the MsgBox "Machine already exists. Please select from dropdown." still pops up. For some reason it will not do anything if the value = False. Can someone let me know what is wrong with the code? If you need anything additional, please let me know. Thanks!

    Sub GoChange()
    On Error Resume Next
    Dim lReply As Long
    Dim inputWks As Worksheet
    Dim lRsp As Long
    If inputWks.Range("MachineName") = True Then
    MsgBox "Machine already exists. Please select from dropdown."
    Exit Sub
    Else
    If inputWks.Cells("MachineName") = False Then
    lRsp = MsgBox("Machine not in database. Add to dropdown?", vbQuestion + vbYesNo, "New Machine")
    If lRsp = vbYes Then
    Range("MachineList").Cells(Range("MachineList").Rows.Count + 1, 1) = Range("$J$6")
    Else
    MsgBox "Please select Machine that is in the database."
    End If
    End If
    End If
    End Sub

  2. #2
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,325

    Re: VBA to Automatically add to range for drop down menu and prevent duplicates

    Hi jackieA6363

    Welcome to the forum. Your post does not comply to rule No 3 of the forum....
    3. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the [#] button at the top of the post window.
    This makes it easier for us to go through the code and copy.....With that being said...Try:
    Please Login or Register  to view this content.
    Good Luck
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the star to left of post [Add Reputation]
    Also....add a comment if you like!!!!
    And remember...Mark Thread as Solved.
    Excel Forum Rocks!!!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] How to prevent my drop down menu activating prematurely???????
    By bralew in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-21-2016, 06:10 AM
  2. [SOLVED] Prevent Printing Unless Drop Down Menu is used
    By soranandivan in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-19-2016, 03:29 PM
  3. Prevent duplicates from a drop down list
    By jame24 in forum Excel General
    Replies: 1
    Last Post: 06-08-2012, 02:14 PM
  4. Drop down menu to automatically send email
    By JONNY981 in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 09-26-2011, 10:52 AM
  5. Replies: 2
    Last Post: 01-08-2010, 09:11 AM
  6. Prevent delete on drop down menu
    By nigelog in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-09-2008, 06:29 AM
  7. Edit Menu will not automatically drop down anymore
    By Irene Pai in forum Excel General
    Replies: 4
    Last Post: 01-25-2006, 11:50 AM

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