Results 1 to 2 of 2

Having a macro check for changes in two drop down lists and fill in cells with data (2013)

Threaded View

  1. #1
    Registered User
    Join Date
    09-20-2013
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    1

    Having a macro check for changes in two drop down lists and fill in cells with data (2013)

    Hi, I am new to the forums and new to macros as well. I appreciate any help that you can give me.

    What I'm trying to do is have two drop down lists that are right next to each other, this is already done, and have a macro check these two lists. So far this is working. Then depending on what is entered into the cells, the macro will take data from another tab and insert it into another cell on the first page. I've accomplished this with one cell and it works fine. However whenever I try to make it import two values, which are right next to each other, it gives me the error "value" of object "range" failed. Below is a part of my code, there are many more if statements because there are many items in the drop down list, however it is not necessary to upload the entirety of it. I'm sure there may be better ways to write this rather than a TON of if statements, but I started it out this way so I'm continuing onward.





    Private Sub Worksheet_Change(ByVal Target As Range)
    
    
    a = ActiveCell.Row
    
        'Coil Handling Equipment
        If Worksheets("Automated Production Equipment").Cells(a, 3).Value = "Coil Handling Equipment" And Worksheets("Automated Production Equipment").Cells(a, 4).Value = "Perfecto" Then
            Worksheets("Automated Production Equipment").Cells(a, 5).Value = Worksheets("Production Equipment").Cells(13, 5).Value
            Worksheets("Automated Production Equipment").Cells(a, 6).Value = Worksheets("Production Equipment").Cells(13, 6).Value
            ElseIf Worksheets("Automated Production Equipment").Cells(a, 3).Value = "Coil Handling Equipment" And Worksheets("Automated Production Equipment").Cells(a, 4).Value = "ASC" Then
            Worksheets("Automated Production Equipment").Cells(a, 5).Value = Worksheets("Production Equipment").Cells(14, 5).Value
    
             Else
             Worksheets("Automated Production Equipment").Cells(a, 5).Value = 0
        End If
    End Sub




    Edit: I have the macro in the sheets own module, just fyi. Also, the line I am trying to is "Worksheets("Automated Production Equipment").Cells(a, 6).Value = Worksheets("Production Equipment").Cells(13, 6).Value" Without this line everything works fine.



    Edit 2: I solved this by using Application.EnableEvents = False. Before any of my if statements I use Application.EnableEvents = True, then when I get into my if statement and it is found try, I first set it equal to False then do everything and then when it exits the if statement but before it ends sub, i set it back to true.
    Last edited by arlu1201; 09-21-2013 at 02:36 AM. Reason: Use code tags in future.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 2
    Last Post: 09-07-2013, 03:55 AM
  2. Stock Check Spreadsheet / drop down lists
    By richardson.cr in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-15-2011, 02:59 PM
  3. Auto fill with one of two drop down lists...?
    By Synthia in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 01-02-2010, 05:57 PM
  4. Macro to fill cells when a value is selected from Drop Down List
    By TRJJK73 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-17-2009, 05:13 AM
  5. Drop-Down Lists: Can we fill 2 columns at the same time?
    By HarvardMajesty in forum Excel General
    Replies: 5
    Last Post: 05-18-2009, 09:07 PM

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